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
With a heat exchanger, the temperature of the process fluid can be measured with a temperature-
Ainat [17]
The answer is outlet cooling or process
6 0
3 years ago
History timeline: who developed what elements first Windows OS and Apple OS?
Harrizon [31]

Answer:

i think bill gates

Explanation:

5 0
3 years ago
Read 2 more answers
You cannot then move and resize the control on the form as desired with your mouse TRUE OR FALSE​
Sindrei [870]

Answer:

False

Explanation:

4 0
2 years ago
Read 2 more answers
Read the following example cover letter:
enot [183]

Answer:

All should be added.

Explanation:

All of these are important to your cover letter to make it seem professional.

Hope this helped

3 0
3 years ago
Read 2 more answers
The ____ provides access to the Internet may also be internal.
dmitriy555 [2]
Local area network (LAN)
7 0
3 years ago
Read 2 more answers
Other questions:
  • How many homes can be warmed by one bugatti
    11·2 answers
  • According to COSO, which of the following components addresses the need to respond in an organized manner to significant changes
    14·1 answer
  • Pressing the e key while in edit mode will exit the interaction mode<br><br> true<br><br> false
    7·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • What is a short sequence of characters that appears at the end of a filename and is preceded by a period called __________
    5·1 answer
  • If you copy and paste from someone else's document (such as a website, a friend's paper, an instructor's solutions manual, etc.)
    15·1 answer
  • Why is information broken down into packets
    15·1 answer
  • During system testing, developers test the program in an environment that is very similar to how the program will eventually be
    11·2 answers
  • Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the cou
    8·1 answer
  • Write a HTML program as shown in the output.​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!