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
Company that offers Internet access to individuals and businesses. This device connects two or more networks and directs the flo
Ganezh [65]

Answer:

ISP is the correct answer to the following question.

Explanation:

ISP(Internet Service Provider) is the company or an organization which provides the internet connection or access to any persons, individuals or any company. It is the device that connects networks and direct flow of the data or information through the network. If you want to connect through ISP then, you have to connect this device to the computer system.

5 0
4 years ago
How to create a delete button in Python?
deff fn [24]

Answer:

class Db_test(models.Model):

   name = models.CharField(max_length=50)

   comment = models.CharField(max_length=200)

   created = models.DateField(auto_now_add=True)

   modified = models.DateField(auto_now=True)

   class Meta:

       db_table = "db_test"

Explanation:

5 0
3 years ago
What does it mena when they say "all germs are germs"
KiRa [710]

Answer:it means that germs are germs germs are reproductive they split apart from one another to create more germs.

Explanation:

7 0
3 years ago
Virtualization, like cloud computing, is a technology that can be useful for _____ sites. hot warm business cold
natima [27]

Answer: Hot sites

Explanation:

 Virtualization in the cloud computing is the technology that are useful for the hot sites. It basically making the virtual image of the network devices so that it can be easily use multiple machine at the similar time.

There are various types of benefits of the virtualization in the cloud computing are as follow:

  • It protect the system from the system failure.
  • It is the cost effective technology.
  • By using this we can easily transfer the data from the physical storage to the virtual server.
8 0
3 years ago
PLEASEEEE PLEASEEE HELPPPP
olga nikolaevna [1]

Explanation:

you need a better pic if possible, it's kinda hard to read the question.

4 0
3 years ago
Other questions:
  • A user calls your help desk and says that he is trying to configure his Word document so that the text within his paragraphs is
    15·1 answer
  • Short Essay on the history of Computer​
    6·2 answers
  • You're setting up some VMs to test an application you're considering making available to employees of the small company you work
    9·2 answers
  • If the computer has an encrypted drive, a ____ acquisition is done if the password or passphrase is available. a. passive b. sta
    8·1 answer
  • Which of the following is not a key way that a LAN shares
    15·1 answer
  • In the early days of photography, cameras were limited to professional photographers because of the knowledge needed to work the
    9·2 answers
  • Employers are looking for an employee?<br>​
    9·1 answer
  • How can you make a search phrase more effective?
    11·1 answer
  • Fill in the Blank
    10·2 answers
  • Show that ALLDFA is in <img src="https://tex.z-dn.net/?f=%5Cmathrm%7BP%7D" id="TexFormula1" title="\mathrm{P}" alt="\mathrm{P}"
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!