Your time machine is capable of going forward in time up to 24 hours. The machine is configured to jump ahead in minutes. To enter the proper number of minutes into your machine, you would like a
int hours, minutes;
bool isAM;
For example, to represent 11:50 PM, you would store:
hours =11
minutes = 50
isAM = false;
This means that you need six variables to store a start and future time. Write a program that allows the user to enter a start time and a future time. Include a function named computeDifference that takes the six variables as parameters that represent the start time and future time. Your function should return, as an int, the time difference in minutes. For example, given a start time of 11:59 AM and a future time of 12:01 PM, your program should compute 2 minutes as the time difference. Given a start time of 11:59 AM and a future time of 11:58 AM, your program should compute 1439 minutes as the time difference (23 hours and 59 minutes).
You may need “AM” or “PM” from the user’s input by reading in two character values. (Display 2.3 illustrates character input.) Characters can be compared just like numbers. For example, if the variable aChar is of type char, then (aChar == ‘A’) is a Boolean expression that evaluates to true if aChar contains the letter A.
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Problem Solving with C++ - MyProgrammingLab
Additional Engineering Textbook Solutions
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Artificial Intelligence: A Modern Approach
Database Concepts (8th Edition)
Database Concepts (7th Edition)
C Programming Language
Computer Science: An Overview (12th Edition)
- Write a program that computes the theoretical flame temperature when a mixture of methane, propane, n-butane, and n-pentane (0% to 100& methane in 5% increments; 0 to 100 mol% propane in 5% increments; 0% to 100% mole n-butane in 5% increments) at 25°C is burned with excess air (0% to 100% excess in 5% increments) preheated to preheated to (50°C to 200°C in 10°C increments)arrow_forwardWrite a program that mimics a calculator. The program should take as input two integersand the operation to be performed. It should then output the number, the operator and theresult. (For division, if the denominator is zero, output an appropriate message).arrow_forwardWrite a program that does temperature converter :\n", "- The user will enter if he wants the result in Celsius or in Fahrenheit. Use the input function to read this option. \n", "- Ask the user the value of the temperature he wants to convert. Use the input function to read this value and convert accordingly.\n", "- If the user wants the temperature in Fahrenheit compute: $ Fahrenheit = Celsius*5/9+32$.\n", "- If the user wants the Celsius compute as follows: $ C = (F-32)*5/9 $.\n"arrow_forward
- Write a program in C language to simulate tossing a “fair” coin. Allow the user to enter the number of tosses.Print the number of tosses that yield heads and the number of tosses that yield tails.What should be the percentage distribution of heads and tails? (Use the function rand_int)arrow_forwardYou have been hired to help write the software for an automatic change dispenser, the kind you seeattached to a cash register that automatically dispenses the right coins depending on the amount ofchange that’s owed to the customer. Write a program that first prompts for a number from 0 to 99(representing the amount of change that is due) and then outputs the number of quarters, dimes,nickels, and pennies that should be dispensed- in Pythonarrow_forwardWrite a program that takes as input five numbers and outputs the mean (average) and standard deviation of the numbers. If the numbers are x1,x2,x3,x4,andx5, then the mean is x=(x1+x2+x3+x4+x5)/5 and the standard deviation is: s=(x1x)2+(x2x)2+(x3x)2+(x4x2)+(x5x2)5 Your program must contain at least the following functions: a function that calculates and returns the mean and a function that calculates the standard deviation.arrow_forward
- Write a program that computes the earnings per shift for a babysitter. A babysitter charges $10 per hour before noon and $15 after noon. The program reads the starting time in hours and minutes and the ending time in hours and minutes. All times are between 8:00 am, and 7:59 pm, using a 12-hour clock. For example, you should consider hour 8 as 8 am and hour 6 as 6pm. The program should check the validity of the inputs as follows. 1) Hours are from 0-11 (0 for noon). 2) Minutes are from 0-59. 3) The start time must be before noon. 4) The end time must not be before 1pm. The program should display specific warnings regarding the above when the user submits invalid input; the program should prompt the user to re-enter the times again. The program should output the total hours worked and the total earnings per shift. Example: >9h 20m to 6h 15m You have worked 8 hours and 55 minutes in this shift, earning $120.417 Important Notes: Please do this in C++ Programming Do not use any…arrow_forwardWrite a program that calculates the potential energy of 3 charges q1 = 1, q2 = 2, q3 = 3located at points (1, 2, 3), (3, −4, −5), and (−4, 2, −6) respectively. The units are coulombs forcharge and meters for coordinates. The energy is given by the expressionarrow_forwardWrite a program that prompts the user to enter a value for a variable named x and then prompts the user to enter a value for y. Both prompts should use the Matlab input function. The program then checks if the value of x is greater than the value of y. If so, display a message to the command window telling the user that x is greater than y, otherwise display a message to the command window telling the user that y is greater than or equal to x. Use symbolic expressions and the subs function to determine the value of E in ? = ? ? 2 when m is 10. Note that c is approximately 186,000 miles per second. You must substitute in values for both m and c. Your answer should be: 3.4596e+11 aka 345960000000arrow_forward
- Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For division, if the denominator is zero, output an appropriate message.) Some sample output as follows: 3 + 5 = 8 4 * 7 =28 6 / 0 Error! Division by zero is not allowed.arrow_forwardPlease answer it in Python Suppose we play a game where each round takes place in the following way: first, we roll a dice, and its result gives the number of points at stake. Then, the player can, if he wishes, trigger his bonus "double account" or his bonus "triple account". Then, the player answers a number of questions, and calculates his percentage of correct answers. The points awarded to the player for that round are then calculated based on the percentage of correct answers and the number of points in play rounded to the nearest integer (for example, with 50% correct answers and 6 points in play, the player gets 3 points; with 45% correct answers and 8 points in play, the player gets 4 points). Finally, this number of points is possibly multiplied by two or three if the corresponding bonus has been used. Write a function points_match that takes as an argument the percentage, the number of points at stake, and as an optional argument the multiplier (which is worth 2 in a double…arrow_forwardWrite a program that determines the distance to a lightning strike based onthe time elapsed between the flash and the sound of thunder. The speedof sound is approximately 1100 ft/ sec and 1 mile is 5280 ft.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning