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
Oksana_A [137]
3 years ago
12

Write a function DrivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar

cost to drive those miles. All items are of type double. If the function is called with 50 20.0 3.1599, the function returns 7.89975. Define that function in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three times. Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements.
Computers and Technology
1 answer:
stira [4]3 years ago
5 0

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// function to calculate cost

double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon){

  double cost;

  //Expression to compute cost

  cost = drivenMiles / milesPerGallon * dollarsPerGallon;

  return cost;

}

// main function

int main()

{

   double drivenMiles, milesPerGallon, dollarsPerGallon;

  //initialise the variables

  drivenMiles = 50;

  milesPerGallon = 20.0;

  dollarsPerGallon = 3.1599;

  //Call function

  double cost = DrivingCost(drivenMiles,milesPerGallon,dollarsPerGallon);

  //Display result

  cout<<"Driven miles : "<<drivenMiles<<endl;

  cout<<"Miles per Gallon : "<<milesPerGallon<<endl;

  cout<<"Dollars per Gallon : "<<dollarsPerGallon<<endl;

  cout << fixed << setprecision(2);

  cout<<"The total driving cost : "<<cost ;

  return 0;

}

Explanation:

Declare and initialize drivenMiles with 50, milesPerGallon with 20.0 and dollarsPerGallon with 3.1599.Call the function DrivingCost() with these parameters,This will calculate the cost and return the value.Print the result after getting the cost.Similarly we can calculate cost for drivenMiles equals to 10 and 400 miles also.

Output:

Driven miles : 50

Miles per Gallon : 20

Dollars per Gallon : 3.1599

The total driving cost : 7.90

You might be interested in
What does % find on edhesive??
statuscvo [17]

Answer:

Explanation: What is that word you typed?

3 0
3 years ago
......... mi2hej<br><br>ejid8eo19o1b2bxhxjxjdnneejk2929nr
Mila [183]

Answer:

hi  thsu si s5

Explanation:

brace use

5 0
2 years ago
Read 2 more answers
A strategic business unit​ (SBU) of a major corporation has high market share in its​ industry, but the growth rate of the indus
VLD [36.1K]

Answer:

Cash cow

Explanation:

A cash cow is seen or made reference to as that part of a business, investment, or product that provides a steady income or profit.

Basically a cash cow is a business unit, product line, or investment that has a return on assets (ROA) greater than the market growth rate. This is expressed with an Idiom to mean that it produces "milk" that is profit long after the cost of the investment has been recouped.

The strategic business unit of this organization having high market share in its​ industry, but the growth rate of the industry is expected to be stagnant over the long run is simply yielding steady profit for the corporation through its high market value and this will continue for longer because it has to be at that high rate for a long period of time.

The SBU can be categorised as acting as the cash cow for that corporation.

6 0
3 years ago
Read 2 more answers
Which of the following devices are least likely to deny a connection inline when an attack is detected? (select 2)
user100 [1]

Answer: Option (A) & (D) are correct.

Layer 2 switch is commonly referred to as a type of network or device switch that tends to work on data link layer and use MAC addresses in order to determine the route through which the frames are forwarded.

An IDS known as intrusion detection system is commonly referred to as a device or application that controls a network for malevolent activity and its policy violations.

7 0
2 years ago
Wice each lunar month, all year long, these tides occur. Whenever the Moon, Earth and Sun are aligned, the gravitational pull of
DENIUS [597]
E)   none of those   Adds; Spring
8 0
3 years ago
Other questions:
  • Text rotation is also called _________________.
    7·1 answer
  • Tornado Alley is located in the middle of the United States, extending from Texas up through the Dakotas. The above statement is
    14·1 answer
  • How to write a program converting RGB to CMYK in python
    6·1 answer
  • Given the commands below, what do they do? for (position = 1 through aList.getLength()/2) { a = aList.getEntry(aList.getLength()
    11·1 answer
  • What is TLB for? Why TLB? Given the following number, what is theeffective memory access time?
    11·1 answer
  • What are minimum computer requirements for a software program?
    5·1 answer
  • As a general rule, what is the size of a brochure?
    11·1 answer
  • Convert each of the fo" wing base ten representations to its equivalent binary form a. 6 b. 13 C. d. 18 e. 27
    6·1 answer
  • PLZZZZZZZZZZ HELP ME OUT THIS DUE TODAY AND NEED SOMEONE HELP!!!!!plzzzzzzzzzzz i begging you!!!
    11·1 answer
  • JAVA
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!