1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Goshia [24]
4 years ago
5

Write a program that allows the user to enter a start time and a future time. Include a function named compute Difference that t

akes 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 a char is of type char, then (a_char == 'A')is a Boolean expression that evaluates to true if a_char contains the letter A.
Computers and Technology
1 answer:
Aleonysh [2.5K]4 years ago
7 0

Step 1

Following is the c++ program:

Variables used:

startHours, startMins are used to store the starting time of time machine.

futureHours, futureMins are used to store the future time of time machine.

xAM variable is used to store meridiem of start and future time.

isSAM is boolean variable that is true if starting time is AM.

isFAM is boolean variable that is true if future time is AM.

 

Functions:

main() is used to call computeDifference() function that will calculate the difference between the start and future time.

computeDifference() takes as input six variables from the user and then apply the following logic to compute the difference between the start and future time:

If Meridien of both start and future time are the same, then simply subtract the start time from the future time.

Difference = future minutes – start minutes

If Meridien of both start and future time are different, then apply the following formula to calculate difference:

Difference = (12 * 60 – start minutes) + future minutes

Step 2

Program :

#include <iostream> //header file for input and output

 

using namespace std;

//calculate the time difference(in minutes) between start time and future time.

int computeDifference(int startHours, int startMins, bool isSAM, int futureHours, int futureMins, bool isFAM) {

 int difference = 0; //to store difference

 startMins = startHours * 60 + startMins; //converting in minutes.

 futureMins = futureHours * 60 + futureMins; //converting in minutes.

 //applying formula for difference.

 if (isSAM == isFAM) {

   difference = futureMins - startMins;

 } else if (isSAM == true && isFAM == false) {

   difference = (12 * 60 - startMins) + futureMins;

 }

}

int main() {

 int startHours, startMins; //it will store start time

 int futureHours, futureMins; //it will store future time.

 string xAM; //it will store meridiem.

 bool isSAM; //it will be true if start time is AM.

 bool isFAM; //it will be true if future time is in AM.

 int difference = 0; //it will store difference.

 cout << "Enter start time of time machine as 'HH MM AM/PM': "; //take input from

You might be interested in
Zach wants to learn a programming language to create games and applications. this programming language will also create web appl
Mkey [24]

Answer:

JavaScript is a good option

6 0
3 years ago
Read 2 more answers
Suppose we used an Internet Addressing protocol that used 4 bits to encode a single address. How many devices would be supported
Allushta [10]
C. is the answer my guy
8 0
3 years ago
Not a subject question but please help
Doss [256]

Answer:

You go to account settings, edit your profile and click preferences and then go to choose level and put which grade u are in the options r middle school, high school, and college

Explanation:

8 0
3 years ago
Read 2 more answers
This is gonna be very long but I have no idea what to do, I'm confused.
kaheart [24]

for such experiment, you do it with care and to acquire and determine to put experience in it

Explanation:

because without you been or using experience the experiment will not correct

8 0
3 years ago
Which relationship is possible when two tables share the same primary key?
patriot [66]

When two tables share the same primary key, they share a

A. one-to-one relationship.

Explanation:

  • One-to-one relationship is a type of cardinality that refers to the relationship between two entities A and B in which one element of A may only be linked to one element of B, or the opposite way.
  • A one-to-one relationship in a relational database occurs when one parent record or field has either zero or one child record only.
  • These relationships are the easiest to represent in databases because both the parent and child records may be in the same table.
  • One-to-one relationships associate one record in one table with a single record in the other table.
  • These relationships are frequently used to indicate critical relationships so you can get the data you need to run your business.
  • A one-to-one relationship is a link between the information in two tables, where each record in each table only appears once.
8 0
4 years ago
Other questions:
  • Which protocols are TCP/IP application layer protocols? (choose all that apply)
    5·2 answers
  • A printer is connected locally on Computer1 and is shared on the network. Computer2 installs the shared printer and connects to
    10·1 answer
  • А.<br> is the highest education degree available at a community college.
    6·1 answer
  • I need an answer and fast What happens if a sequence is out of order?
    5·2 answers
  • Compare and contrast CD and DVD?
    10·2 answers
  • In spreadsheets, a cell reference is also referred to as which of the following? A. active cell B. axis C. cell address D. entry
    9·1 answer
  • Which camera required the photographer to project the image on paper
    9·2 answers
  • Usually, in organizations, the policy and mechanism are established by the:
    14·2 answers
  • Imagine that a time machine has transported you back to an earlier civilization or historical era. Poking through your backpack,
    12·1 answer
  • I just logged onto brainly and all my questions were deleted and i lost 2 brainliest. What has brainly done to my account I also
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!