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
Write a recursive method called repeat that accepts a string s and an integer n as parameters and that returns s concatenated to
svp [43]

Answer:

public static String repeat(String text, int repeatCount) {

   if(repeatCount < 0) {

       throw new IllegalArgumentException("repeat count should be either 0 or a positive value");

   }

   if(repeatCount == 0) {

       return "";

   } else {

       return text + repeat(text, repeatCount-1);

   }

}

Explanation:

Here repeatCount is an int value.

at first we will check if repeatCount is non negative number and if it is code will throw exception.

If the value is 0 then we will return ""

If the value is >0 then recursive function is called again untill the repeatCount value is 0.

6 0
3 years ago
Which is most likely to cause confusion, hinder thinking, and prevent quick access to resources in a study environment? phones c
OverLord2011 [107]
Clutter will cause the most problems when you are trying to study because <span>If you’re unable to get through the material clogging up your </span>neural<span> networks, so the theory goes, you’ll be slower and less efficient in processing information. As a result, you’ll be incapacitated when it comes to short-term memory tasks, and even in longer-range mental exercises when you have to come up with information you should know, such as names of people, that you can no longer find within your disorganized repository of knowledge.

Hope this helps, 

kwrob</span>
3 0
4 years ago
Read 2 more answers
What is the opportunity cost of computers when moving from point A to point B? -15 DVDs b. What is the opportunity cost of compu
oee [108]

Answer:

Increasing

Explanation:

Generally in economics, opportunity cost is the benefit that a person, a business, or an investor forgo or missed when he chooses one alternative instead of the other.

Under production, opportunity cost occurs when a producer sacrifice the production of one for the production of another good. Using good X and Y as examples, opportunity cost is measured by the number of units of good Y that the producer gives up in order to produce one or more units of good X.

In the question, the two products used are computers and DVD. The -15, -18 and -20 implies that producing an extra unit of computer by moving from point A to point B, point B to C, and point C to D, 15, 18 and 20 units of DVD respectively have to be given up.

Since 20 is greater than 18 and 18 is also greater than 15, it therefore implies as we produce more computers, the opportunity cost, which are the number of DVDs given up at each point, are increasing.

I wish you the best.

5 0
3 years ago
What is the highest strength for the leviathan axe in god of war
kicyunya [14]

Answer:

85

Explanation:

5 0
3 years ago
Read 2 more answers
The physical components of information technology, which can include the computer itself plus peripherals such as storage device
yarga [219]
The correct answer should be Hardware
8 0
3 years ago
Other questions:
  • Preserving confidentiality, integrity, and availability of data is a restatement of the concern over interruption, modification,
    15·1 answer
  • A(n) __________________ device is a breath analyzer on your vehicle that is electronically connected to the ignition.
    11·1 answer
  • 30 POINTS!!
    15·2 answers
  • List the various types of social media that have been covered in the tutorial. Mention the key purposes for which each media typ
    9·1 answer
  • When designing a suitable and safe flexibility training program, you should set reasonable and appropriate goals depending on wh
    15·1 answer
  • Sharon is responsible for the security on web applications. She’s looking to see if all applications have input validation. What
    12·1 answer
  • Please I need all the help I can get
    11·1 answer
  • What command can you use if you accidentally delete a sentence in your document?
    13·2 answers
  • What do you mean by computer ethics?​
    9·1 answer
  • A(n) _____ is any group of characters enclosed within either double or single quotation marks in javascript.
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!