Exponents Program - SOLUTION

New Concepts to be applied for the assignment

  • Input and output

  • Variables

  • Formulas

  • Decision making/branching

  • Looping


Aside from the 'main()' method you are not to write static methods for this assignment. (If you don't know what I'm referring to by static methods, I will be discussing this topic later in the course).
Description



 


  • Define one class 'Exponents', your code will be all be contained in the main() method of this class. The file name of course must be called "Exponents.java". (1 mark for an empty class and method definition, additional marks will be awarded when you implement the features listed below). (Y





 


  • The program will prompt the user for a base and a power (1 mark each x 2 = 2 marks total) either of which can be any non-negative integer





 


  • The program can correctly calculate an exponent when the power is zero (the result is just one). (1 mark)





 


  • The program can correctly calculate (using a loop) an exponent when the power is greater than zero. (2 marks)





Powered by