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
Nady [450]
3 years ago
6

Two cars A and B leave an intersection at the same time. Car A travels west at an average speed of x miles per hour and car B tr

avels south at an average speed of y miles per hour. Write a program that prompts the user to enter: The average speed of both the cars The elapsed time (in hours and minutes, separated by a space) Ex: For two hours and 30 minutes, 2 30 would be entered

Computers and Technology
1 answer:
drek231 [11]3 years ago
3 0

Answer:

Here is the C++ program:

#include <iostream>  // to use input output functions

#include <cmath>  // to use math functions like sqrt()

#include <iomanip>  //to use setprecision method

using namespace std;   //to access objects like cin cout

int main ()  {  //start of main function

  double speedA;  //double type variable to store average speed of car A

  double speedB;  //double type variable to store average speed of car B

  int hour;  //int type variable to hold hour part of elapsed time

  int minutes;  //int type variable to hold minutes part of elapsed time

  double shortDistance;  // double type variable to store the result of shortest distance between car A and B

  double distanceA;  //stores the distance of carA

  double distanceB;  //stores the distance of carB

  double mins,hours;   //used to convert the elapsed time

cout << "Enter average speed of car A: " << endl;  //prompt user to enter the average speed of car A

cin >> speedA;   //reads the input value of average speed of car A from user

cout << "Enter average speed of car B: " << endl ;  //prompt user to enter the average speed of car B

cin >> speedB;   //reads the input value of average speed of car A from user

cout << "Enter elapsed time (in hours and minutes, separated by a space): " << endl;  //prompts user to enter elapsed time

cin>> hour >> minutes;    //reads elapsed time in hours and minutes

  mins = hour * 60;  //computes the minutes using value of hour

  hours = (minutes+mins)/60;     //computes hours using minutes and mins

distanceA = speedA * (hours);  // computes distance of car A

distanceB = speedB * (hours);   //computes distance of car B

   shortDistance =sqrt((distanceA * distanceA) + (distanceB * distanceB));   //computes shortest distance using formula √[(distanceA)² + (distanceB)²)]

cout << "The (shortest) distance between the cars is: "<<fixed<<setprecision(2)<<shortDistance;

//display the resultant value of shortDistance up to 2 decimal places

Explanation:

I will explain the program with an examples:

Let us suppose that the average speeds of cars are:

speedA = 70

speedB = 55

Elapsed time in hours and minutes:

hour = 2

minutes = 30

After taking these input values the program control moves to the statement:

mins = hour * 60;  

This becomes

mins = 2 * 60

mins = 120

Next

hours = (minutes+mins)/60;

hours = (30 + 120) / 60

         = 150/60

hours = 2.5

Now the next two statements compute distance of the cars:

distanceA = speedA * (hours);  

this becomes

distanceA = 70 * (2.5)

distanceA = 175

distanceB = speedB * (hours);

distanceB = 55 * (2.5)

distanceB = 137.5

Next the shortest distance between car A and car B is computed:

shortDistance = sqrt((distanceA * distanceA) + (distanceB * distanceB));

shortDistance = sqrt((175 * 175) + (137.5 * 137.5))

                        = sqrt(30625 + 18906.25)

                        = sqrt(49531.25)

                        =  222.556173

shortDistance =  222.56

 

Hence the output is:

The (shortest) distance between the cars is: 222.56        

You might be interested in
What is one concern associated with web-based applications?
damaskus [11]

Answer:

Security

Explanation:

If you dont have security, all the other will be broken, its like laws of physics

5 0
3 years ago
Which of the following is an example of a problem that could be attributed to poor ergonomics?
Alenkasestr [34]

I would say B because Carpal tunnel syndrome is caused by repetitive flexing and extending of tendons (it gets worse if it's for a long time) pressure on the median nerve can cause pain numbness and weakness in the hand and wrist. So this is the best answer as it shows there is a poor working environment it would be better if there was something as simple as a mouse pad that the wrist could lay on while using the mouse for example or using padding on the desk could improve the working environment and prevent this.

4 0
3 years ago
Why is it more secure to require a user to press ctrl+alt+delete to log on rather than displaying the windows welcome screen?
Levart [38]
Let's say for example you have a toddler, or a pet. Let's say a cat. If the ctrl+alt+delete wasn't there. It would go straight to entering the password. Now let's say your child or pet likes to press the keys for a while. If they manage to press enter and enter the incorrect password. Eventually it will lock up your computer.
5 0
3 years ago
10 sentences about computer parts.
Ahat [919]
One computer part is the CPU, it’s a piece of hardware the last allows your computer to access and interact all the applications and programs. The first ever CPU chip was invented around 4 decades ago. The keyboard is another computer part and it allows the user to type letters and numbers. There are about 104 keys on a keyboard and there are different parts in it. Some of the parts include, control keys, function keys, navigation keys, numeric keypad, and so on. A mouse is another device used with the keyboard to position the cursor. It’s a hand held device that detects two-dimensional motion relative to a surface. This motion is typically translated Into the motion of a pointer on a display, which allows a smooth control of the graphical user. Memory is a device to store all of your information and saved data. The motherboard is the backbone that tied together the computers components at one spot.
6 0
2 years ago
A ___________ allows Internet telephony service providers to deliver telephony services and unified communications applications
Firlakuza [10]

Answer: SIP Trunk

Explanation:

   The SIP is stand for the session initiation protocol trunk is one of the service that is specifically provided by the service provider and the main purpose of the SIP trucking is to manage the VoIP call process (Voice over IP).

According to the given question, SIP is one of the protocol that allow telephony services for the communication purpose and it also offer the video, Message, media and the voice application and these process are control by using this type of technology.  

 Therefore, SIP Truck is the correct answer.  

8 0
3 years ago
Other questions:
  • Which is true about POP3 and IMAP for incoming email?
    6·1 answer
  • How many times do you usually use npm?<br> Put your answer in the box.
    6·1 answer
  • Ports on the motherboard can be disabled or enabled in ____ setup. RAM Firmware Northbridge BIOS
    8·1 answer
  • _____ _____ deals with the definitions properties of mathematical models of computation.
    8·1 answer
  • Hi need help on this <br> what is cyberspace
    14·1 answer
  • What is the IEEE 802 standards name for a wireless network that is limited to one person's workspace?
    14·1 answer
  • List three different sets of keywords that could be used to search for information on how to
    15·1 answer
  • Explain the term creating in word processing​
    12·1 answer
  • Why is my internet slow even though the speed test says it is fast
    12·1 answer
  • Which characteristics support an agile mis infrastructure?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!