Question
Java Programing Problem 1: Phone Call (10 points) Write a program that computes the length and cost of a phone call that begins and ends
Java Programing
Problem 1: Phone Call (10 points)
Write a program that computes the length and cost of a phone call that begins and ends within the same day - i.e., a 24-hour period starting at 0 hours, 0 minutes, and ending at 23 hours, 59 minutes.
The program must prompt the user to enter the starting hour, the starting minute, the ending hour, and the ending minute of the phone call, in that exact order. The program must print the length of the phone call in hours and minutes and the total cost of the call, given a cost per minute of $0.33.
You may assume that the user will always enter valid data, i.e., only positive integer values for all hour and minute inputs and an end time that is always later than the start time, with all times based on a 24- hour clock.
Additional requirements:
- Use named constants for all constant values, such as minutes per hour and cost per minute. Then use those constants, rather than their numeric values, in any calculations involving them. Only you, the coder, can change the value of a constant; it cannot be overwritten during program execution. In addition, named constants make code easier to follow. For full credit, use the naming convention for constants described in the Style Requirements section of this assignment.
- Round currency values to at most 2 decimal places in your output. You do not need to add an additional 0 to output that has only one digit after the decimal point, such as $15.4.
Following is a sample interaction that demonstrates how your program should work. Note that the user input appears in boldface in the handout (it will not appear that way in Eclipse). Your output must include appropriate spacing between literal text and input and output values as well as a $ before the cost output.
Sample interaction: shown below
This program computes the length and cost of a phone call.
Enter starting hour: 9
Enter starting minute: 58
Enter ending hour: 13
Enter ending minute: 2
The length of the phone call is 3 hours 4 minutes The total cost of the phone call is: $60.72
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