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
Why do companies use online collaborative productivity software.
vladimir2022 [97]

Why do companies use online collaborative productivity software? Companies use online collaborative productivity software to allow employees to share document such as reports or spreadsheets and make edits or comments.

4 0
2 years ago
Please help with attached file
Paul [167]
Where is the attached file?
8 0
3 years ago
Read 2 more answers
Patient letters created from __________ use structured data and do not require a large amount of typing from the medical assista
umka2103 [35]
Templates I think. not sure
3 0
3 years ago
What is meant by check digit
Strike441 [17]

Answer:it is the last number in a general digit

Explanation:

6 0
3 years ago
Why are people's visions of utopias and dystopias subjective?
Leno4ka [110]

Answer:

D. Because the technology needed for one person's utopia may be what creates disaster for another person's dystopia.

Explanation:

3 0
2 years ago
Other questions:
  • Which method tries all possible passwords until a match is found?
    13·1 answer
  • We have a user Sally Smith who we want to grant the ability to launch applications and browse folders. But we do not want her to
    15·1 answer
  • What is the IEEE standard for the Wi-Fi Protected Access 2 (WPA2) security protocol?
    6·1 answer
  • str1=”Good” str2=”Evening” Does the concatenation of the above two strings give back a new string or does it concatenate on the
    14·1 answer
  • Develop a list of privacy protection features that should be present if a website is serious about protecting privacy. Then, vis
    8·1 answer
  • What is the best brand of folders
    13·2 answers
  • Which feature is used to summarize data from multiple worksheets but does not require that the data be in the same location on e
    12·1 answer
  • Which one is the answer for the question.
    11·1 answer
  • The different generation of computer explain in breif?​
    7·2 answers
  • Dynamics
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!