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
The automotive system that connects the engine and the transmission to the wheels is called the
insens350 [35]
I believe the driveshaft 

8 0
2 years ago
Should charter schools allow cell phone use in class?
lawyer [7]

Answer:

yes

Explanation:

4 0
3 years ago
Read 2 more answers
What do you consider to be audit evaluation areas?
skelet666 [1.2K]

Answer:

<em>communications</em><em>,</em><em>risk</em><em>,</em><em>systems</em><em>,</em><em>test</em><em>ins</em><em>,</em><em>procedures</em><em>,</em><em>interviews</em><em>,</em><em>documents</em><em>.</em>

Explanation:

The auditor considers many factors in determining the nature, timing, and extent of auditing procedures to be performed in an audit of an entity's financial statements. One of the factors is the existence of an internal audit function. fn 1 This section provides the auditor with guidance on considering the work of internal auditors and on using internal auditors to provide direct assistance to the auditor in an audit performed in accordance with generally accepted auditing standards.Note: When performing an integrated audit of financial statements and internal control over financial reporting, refer to paragraphs 16-19 of PCAOB Auditing Standard No. 5, An Audit of Internal Control Over Financial Reporting That Is Integrated with An Audit of Financial Statements, for discussion on using the work of others to alter the nature, timing, and extent of the work that otherwise would have been performed to test controls.

Roles of the Auditor and the Internal Auditors

<em>02 </em>

<h2><em>I</em><em> </em><em>HOPE</em><em> </em><em>THIS</em><em> </em><em>HELPS</em><em> </em><em>ALOT</em><em>!</em><em> </em><em>:</em><em>3</em></h2>

3 0
3 years ago
You are using a device that reads the physical addresses contained in incoming data that travels along network cables. Based on
GuDViN [60]

You are using a device that reads the physical addresses contained in incoming data that travels along network cables. Based on the physical address that it reads, the device then forwards the data out one of its ports to reach the destination device. The type of device you are using is router.

<h3>What is Router?</h3>

A router is an hardware device that is used in transferring information or data from a system to another.

The data can also be transfered from one computer networks to another.

Router makes it easier for more than one device to be connected easily without difficult Internet access.

Therefore, The type of device you are using that reads incoming data that travels along network cables is router.

Learn more on router below

brainly.com/question/24812743

#SPJ1

3 0
2 years ago
Net neutrality refers to the idea that Internet service providers (ISPs), including cable Internet and wireless carriers, should
Vedmedyk [2.9K]

Answer:

True is the right answer.

Explanation:

The term net neutrality can be defined as the principle which states that all internet service providers treat all communication channels i.e wired or wireless channels equally.

In net neutrality, there can not be any discrimination on the basis of the website, user, protocol, hardware or application.

In net neutrality, the internet service provider can not charge the user on the basis of some specific content.

Hence the most appropriate answer is true.

8 0
3 years ago
Read 2 more answers
Other questions:
  • If it can be applied, the least-damaging recovery option is ________.
    10·1 answer
  • Why is peer answer always not working? just wondering idk why
    7·2 answers
  • John would like to move from the suburbs into the city, but the rent in the city is very high. John has found an apartment he re
    13·1 answer
  • PLEASEEE HELPPPP me
    13·1 answer
  • To under a clip art you must do the following.
    14·1 answer
  • Which of the following must be configured in certain applications to help ensure data aggregation and data isolation are impleme
    15·1 answer
  • What are the raw materials for the process of photosynthesis​
    6·2 answers
  • The following are part of characteristics of a software requirement specification.
    6·1 answer
  • Kris is the project manager for a large software company. Which part of project management describes the overall project in deta
    11·2 answers
  • Write a summary of five things that you learned about CSS. Do not copy and paste the information. Summarize each point in your o
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!