Question
Homework 3 CMP 167: Programming Methods I Lehman College, City University of New York This work must be completed in your textbook ZYBooks -- CMP-167:
Homework 3
CMP 167: Programming Methods I
Lehman College, City University of New York
This work must be completed in your textbook
ZYBooks -- CMP-167: Programming Methods I by following the link for each problem above.
No other forms of submission will be accepted.No late submissions will be accepted.
Homework 3-1
Write a program that converts a temperature from Fahrenheit to Celsius.
It should do the following:
Prompt the user for input
Read a double value from the keyboard
Calculate the result. Here is the formula: C = (F - 32) * 5 / 9
Format the output to one decimal place.
Your prompt to the user to enter the temperature in Celsius must be:
Enter the Fahrenheit Temperature as a decimal:
Your output must be of the format:
fahrenheitTemperature F = celsiusTemperature C
A sample run with input 75.2 must look like:
Enter the temperature in degrees celsius: 75.2
75.2 F = 24.0 C
A sample run with input 7.5 must look like:
Enter the temperature in degrees celsius: 7.5
7.5 F = -13.6 C
Hint1: Be careful not to use integer division! Here is the formula again: C = (F - 32) * 5 / 9
Hint2: Remember to use printf to format the output.
Please make sure to end each line of output with a newline.
Please note that your class should be named FahrenheitToCelsius.
Homework 3-2
Write a program that converts a number of seconds to the equivalent number of hours, minutes, and seconds.
It should do the following:
Prompt the user for input
Read an integer from the keyboard
Calculate the result
Use printf to display the output
A sample run with input 5000 must look like:
Enter the number of seconds: 5000
5000 seconds = 1 hours, 23 minutes, and 20 seconds
5000 seconds = 01h:23m:20s
A sample run with input 3754 must look like:
Enter the number of seconds: 3754
3754 seconds = 1 hours, 2 minutes, and 34 seconds
3754 seconds = 01h:02m:34s
Hint1: Use integer division
Hint2: Use the modulus operator
Please make sure to end each line of output with a newline.
Please note that your class should be named SecondsConverter.
Homework 3-3
Write a program that converts change into formatted dollars and cents
It should do the following:
Prompt the user for their change in Quarters, Dimes, Nickels, and Pennies
Read the associated integers from the keyboard
Calculate the result
Use printf to display the output as $d.cc
A sample run with inputs 6, 5, 4, 3 must look like: (plural is ok even when grammatically incorrect)
Enter the number of quarters: 6
Enter the number of dimes: 5
Enter the number of nickels: 4
Enter the number of pennies: 3
You entered:
6 quarters
5 dimes
4 nickels
3 pennies
The total in dollars is $2.23
A sample run with inputs 1, 2, 3, 2 must look like:
Enter the number of quarters: 1
Enter the number of dimes: 2
Enter the number of nickels: 3
Enter the number of pennies: 2
You entered:
1 quarters
2 dimes
3 nickels
2 pennies
The total in dollars is $0.62
Hint: Use printf to ensure there is at least 1 digit to the left of the decimal point and at most 2 digits to the right.
Please make sure to end each line of output with a newline.
Please note that your class should be named ChangeConverter.
Homework 3-4
You just returned from a trip. The countries you visited were Jamaica, The Dominican Republic, and Cuba.
You arrived back in the United States with some foreign currency from these countries.
Write a Java program that prompts the user for an amount of each of these foreign currencies.
The program should convert these combined amounts to the total equivalent number of US Dollars.
The program should then output the result.
Use exchange rates for these currencies as follows:
1 Jamaican Dollar = 0.0069 US $ 1 Dominican Peso = 0.017 US $ 1 Cuban Peso = 0.042 US $
The prompts should look like this:
Enter number of Jamaican Dollars : Enter number of Dominican Pesos : Enter number of Cuban Pesos :
The output should be formatted as follows:
US Dollars = $total amount of US Dollars
Hint:
Be very careful with formatting your output. The number should look like it represents money.
System.out.printf( "US Dollars = $%.2f " , totalUnitedStatesDollars );
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started