Write one Java program and satisfy the following requirements: Write a method called cube that accepts one...

80.2K

Verified Solution

Question

Programming

Write one Java program and satisfy the followingrequirements:

  1. Write a method called cube that accepts one integerparameter and returns that value raised to the third power.

  1. Write a method called randomNumber that returns arandom floating-point number in the range of [-20.0, 50.0). (hints:use Random class in the method)

  1. Write a method called findMax that accepts threefloating-point number as parameters and returns the largestone.(hints: use conditional statement in the method)

  1. Overload findMax that accepts one integer parameterrepresenting the amount, the method will read the floating-pointnumber one by one within the amount and return the largest value.(hints: use Scanner class and loop statement in the method)

5. In the main method, invoke the above methods and output theirresults.

Answer & Explanation Solved by verified expert
4.2 Ratings (546 Votes)
import javautilScannerimport javautilRandomimport javalangMathpublic class Main public static void mainString args Scanner innew ScannerSystemin SystemoutprintlnEnter anynumber n read input for abc int    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students