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
ad-work [718]
3 years ago
11

C++

Computers and Technology
2 answers:
Sonbull [250]3 years ago
8 0

Answer:

#include <iostream>

#include<iomanip>

using namespace std;

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

{

  double dollarCost = 0;

  dollarCost = (dollarsPerGallon * drivenMiles) / milesPerGallon;

  return dollarCost;

}

int main()

{

  double miles = 0;

  double dollars = 0;

  cout << "Enter miles per Gallon   : ";

  cin >> miles;

  cout << "Enter dollars per Gallon: ";

  cin >> dollars;

  cout << fixed << setprecision(2);

  cout << endl;

  cout << "Gas cost for 10 miles : " << DrivingCost(10, miles, dollars) << endl;

  cout << "Gas cost for 50 miles : " <<DrivingCost(50, miles, dollars) << endl;

  cout << "Gas cost for 400 miles: "<<DrivingCost(400, miles, dollars) << endl;

  return 0;

}

Explanation:

  • Create a method definition of DrivingCost that accepts  three input double data type parameters drivenMiles,  milesPerGallon, and dollarsPerGallon and returns  the dollar cost to drive those miles .
  • Calculate total dollar cost and store in the variable, dollarCost .
  • Prompt and read the miles and dollars per gallon  as input from the user .
  • Call the DrivingCost function three times  for the output to the gas cost for 10 miles,  50 miles, and 400 miles.

 

Romashka [77]3 years ago
7 0

Answer:

def driving_cost(driven_miles, miles_per_gallon, dollars_per_gallon):

  gallon_used = driven_miles / miles_per_gallon

  cost = gallon_used * dollars_per_gallon  

  return cost  

miles_per_gallon = float(input(""))

dollars_per_gallon = float(input(""))

cost1 = driving_cost(10, miles_per_gallon, dollars_per_gallon)

cost2 = driving_cost(50, miles_per_gallon, dollars_per_gallon)

cost3 = driving_cost(400, miles_per_gallon, dollars_per_gallon)

print("%.2f" % cost1)

print("%.2f" % cost2)

print("%.2f" % cost3)

Explanation:

You might be interested in
Could anyone please answer this?
Anastaziya [24]

Answer:

D

Explanation:

The answer is D because if you're looking for lightweight materials, you'll be dealing with chemistry, and chemistry is sience.

4 0
2 years ago
Can you redact this image
spin [16.1K]

Answer:what???

Explanation:so

What

6 0
2 years ago
DO NOT JOIN ANY Z O O M MEETINGS FROM THIS PERSON! IS A TRAP Please help me get them banned!!!!!
s2008m [1.1K]

Answer:

how do i help?

Explanation:

7 0
3 years ago
Read 2 more answers
Why must the image be reduced when the field of view is widened to take in more of the scene?
fiasKO [112]
The lighting in the shot
8 0
2 years ago
Read 2 more answers
Why is Net WPM a better formula than Gross WPM to calculate typing speed?
sergeinik [125]
<span>Net speed can be calculated by deducting errors in gross wpm which is more accurate </span>
7 0
3 years ago
Read 2 more answers
Other questions:
  • Given the function definition
    12·1 answer
  • When addictions escalate and the individual loses his or her job or drops out of school, _______________.
    12·2 answers
  • Three common risk factors for young drivers and how you plan to minimize these factors.
    13·1 answer
  • How can you rotate and resize your drawing?​
    9·2 answers
  • A<br> is an list of steps to complete a task. *
    9·1 answer
  • What<br>are<br>the features of secondary storage media​
    13·2 answers
  • One way to use contiguous allocation of the disk and not suffer from holes is to compact the disk every time a file is removed.
    13·1 answer
  • name instances in the past where social media has kept you informed about the latest news around the country​
    15·2 answers
  • when two people are in a race, what do you need to know to determine who is the fastest 1 units of speed that are identical 2 th
    10·1 answer
  • Select the correct answer.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!