Problem Solving with C++ (9th Edition)
Problem Solving with C++ (9th Edition)
9th Edition
ISBN: 9780133591743
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 7PP

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 program that can take a start time (in hours, minutes, and a Boolean indicating AM or PM) and a future time (in hours, minutes, and a Boolean indicating AM or PM) and calculate the difference in minutes between the start and future time. A time is specified in your program with three variables:

  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.

Blurred answer
Students have asked these similar questions
The ideal gas law calculates the volume of a gas given the pressure (P), quantity of gas (n), and temperature (T). V = nRT / P is the equation.Due to the fact that we have solely employed integer arithmetic, all numbers will be integer values with no decimal points. R is a constant that will be given as (8314/1000). This produces the same outcome. Provide a gas law software in which the user is requested for and inputs values for n, T, and P, and V is computed and reported. Take care to use the most up-to-date version of this software. Your application should feature an appropriate and functional input prompt, as well as print the results in a sensible way.
Write a computer program for calculating carburization heat treatments. The program should ask the user to provide an input for the carbon concentration at the surface (cs), and the concentration of carbon in the bulk (c0).
This is an exercise to design and write a Python program in good programming style for a simulation of stock price over a period of 100 days. In this exercise, you are asked to simulate the stock price starting at $100.00 for 100 days with a daily fluctuation based on the Normal Distribution with mean = 0.0 & sigma = 0.0125. The program will show the daily stock price, the 7-day minimum, the 7-day maximum, the 7-day average, and the 50-day average. The program should also give an indication of "***" when the stock price drops beyond the 50-day average!

Chapter 4 Solutions

Problem Solving with C++ (9th Edition)

Ch. 4.3 - Write a function definition for a function called...Ch. 4.3 - Write a function definition for a function called...Ch. 4.3 - Write a function definition for a function isDigit...Ch. 4.3 - Write a function definition for a function...Ch. 4.4 - What is the purpose of the comment that...Ch. 4.4 - Prob. 16STECh. 4.4 - Prob. 17STECh. 4.4 - Carefully describe the process of program testing.Ch. 4.4 - Prob. 19STECh. 4.5 - If you use a variable in a function definition,...Ch. 4.5 - Suppose a function named Function1 has a variable...Ch. 4.5 - The following function is supposed to take as...Ch. 4.5 - Prob. 23STECh. 4.6 - Prob. 24STECh. 4.6 - Prob. 25STECh. 4.6 - Prob. 26STECh. 4.6 - Suppose you have two function definitions with the...Ch. 4.6 - This question has to do with the Programming...Ch. 4.6 - Prob. 29STECh. 4 - A liter is 0.264179 gallons. Write a program that...Ch. 4 - Modify your program from Practice Program 1 so...Ch. 4 - The price of stocks is sometimes given to the...Ch. 4 - Write a program to gauge the rate of inflation for...Ch. 4 - Enhance your program from the previous Practice...Ch. 4 - Write a function declaration for a function that...Ch. 4 - The gravitational attractive force between two...Ch. 4 - Prob. 8PCh. 4 - Prob. 9PCh. 4 - Write a program that computes the annual after-tax...Ch. 4 - Write a program that asks for the users height,...Ch. 4 - Modify your program from Programming Project 2 so...Ch. 4 - Write a program that outputs the lyrics for the...Ch. 4 - To maintain ones body weight, an adult human needs...Ch. 4 - You have invented a vending machine capable of...Ch. 4 - Your time machine is capable of going forward in...Ch. 4 - Do Programming Project 11 from Chapter 3 except...
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY