Question: Arithmetic, User Inputs, Scanner Objects, Methods II Part 0 Download the following starter code: Lab 2 a . java Download Lab 2 a . java

Arithmetic, User Inputs, Scanner Objects, Methods II
Part 0
Download the following starter code: Lab2a.java Download Lab2a.java and Lab2b.java Download Lab2b.java
As you progress through the lab, look over the relevant starter code file and make sure you know what material has been provided for you.
Part 1
Lab2a
Write a method called kelvins that takes as input (that is, as argument) a temperature in degrees Fahrenheit (of type double) and returns the temperature in degrees Kelvin (also a double). Here is the mathematical formula for conversion:
Write another method called temperaturePrinter that takes as input (i.e. as argument) two doubles and prints the following message to the screen:
#.## deg. F equals #.## deg. K
Where #.## are correct values in degrees Fahrenheit and Kelvin.
Test your methods with 5 different values for Fahrenheit. Either print the results of each test as they are run, or record the results of the tests in comments.
Part 2
Write a method called secondTime() that takes as argument an integer corresponding to a number of seconds. secondTime() should compute and display the equivalent time in hours, minutes and seconds, printing the result to console in the format:
secondTime(1234); should generate:
1234 seconds ==00:20:34//meaning 0 hours, 20 min, 34 seconds
Hint: Use a tool like Tools4Noobs Links to an external site. to help determine the correct answer so that you can test your code.
Write another method called inSeconds() that takes as arguments three integers: hours, minutes and seconds, computes the exact time in seconds, then returns the total number of seconds and prints the following message to the console:
inSeconds(0,20,34); should generate:
00:20:34==1234 seconds
Write the following tests of your methods and submit the outputs with your codebase.
inSeconds(0,2,0);
secondTime(9001);
inSeconds(24,0,0);
secondTime(3600);
inSeconds(-1,61,-60);
Part 3
Lab2b
Make sure that you are done with Lab2a before you move on to this part. In this exercise you will:
Use two methods from the Math library, namely max and min. Here is a quick introduction to these methods: they each take two numeric inputs (i.e. arguments) and return whichever number is the maximum or minimum (depending on if you are using max or min) of the two. Lets try them out! In main, declare and initialize variables as follows:
double maxNumber1= Math.max(22.3,34.5);
double minNumber1= Math.min(3.6/7.2,3.8/6.9);
double maxNumber2= Math.max(2/3,0.1);
double minNumber2= Math.min(13.5555,13.5556);
What are their values? Write them down somewhere. Now print them to the screen, did you get what you expected? If not, reflect on the reason and ask someone. Make sure you understand how to use these methods before proceeding.
Write a program in main that asks the user of your program to first enter his or her name followed by 3 real numbers (that is, any number from \infty to \infty ). Your program should sort the three numbers in descending order, then print to the screen a greeting to the person and the sorted numbers. For example (your input in blue),
Please enter you name followed by three numbers (space separated):
Leonardo -22.312.22.3
Hi there, Leonardo! Here are the numbers you entered in descending order:
12.22.3 and -22.3
Thank you for using the three-number-sorting system! Good-bye.
Note: You must use the Math.max and Math.min methods introduced above. The class has not covered conditionals, so please avoid using conditionals!
Make sure to run your program several times and test it with several inputs of different order
Submittal:
Submit both Lab2a.java and Lab2b.java files to Canvas by the due date.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!