A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

pottersheep

  • 5 years ago

Guidance please !! Write a method to calculates exponents. Pass 2 values: the number and the exponent it is to be calculated to; return the result. Display the returned value

  • This Question is Closed
  1. pottersheep
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    This is what I did (fail)

  2. pottersheep
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    import java.util.Scanner; public class exponentmethod { public static void main (String args []){ Scanner input = new Scanner (System.in); int total = 0 , first = 0 , second = 0 ; System.out.print("Enter base"); first= input.nextInt(); System.out.print("Enter exponent"); second= input.nextInt(); total= a(first, second); System.out.print("result"+total); } static int result=1; static int a(int t,int y){ return result; int ctr=1; while (ctr!=y){ result = result * t; ++ctr; } } }

  3. pottersheep
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    can I use a loop in my method ? please help........

  4. pottersheep
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i think my return part is wrong but idk how to do it

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    please format your code and put it to pastebin.com or codepad.org or somewhere else

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://pastebin.com/n2uTQdib as i commented about spaces near = it's not essential but it's good practise and you will follow java coding conventions

  7. pottersheep
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Ok here it is http://pastebin.com/AMiaBFDR

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    well you didn't change it at all

  9. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.