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
pshichka [43]
4 years ago
9

Write a function DrivingCost with parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to

drive those miles. All items are of type float. Ex: 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 floats). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three times. Ex: If the input is 20.0 3.1599, the output is: 1.57995 7.89975 63.198 Note: Small expression differences can yield small floating-point output differences due to computer rounding. Ex: (a b)/3.0 is the same as a/3.0 b/3.0 but output may differ slightly. Because our system tests programs by comparing output, please obey the following when writing your expression for this problem. In the DrivingCost function, use the variables in the following order to calculate the cost: drivenMiles, milesPerGallon, dollarsPerGallon.
Computers and Technology
1 answer:
solniwko [45]4 years ago
8 0

Answer:

See explaination

Explanation:

Function DrivingCost(float drivenMiles, float milesPerGallon, float dollarsPerGallon) returns float cost

float dollarsPerMile

//calculating dollars per mile

dollarsPerMile=dollarsPerGallon/milesPerGallon

//calculating cost

cost=dollarsPerMile*drivenMiles

Function Main() returns nothing

//declaring variables

float miles_per_gallon

float dollars_per_gallon

//reading input values

miles_per_gallon = Get next input

dollars_per_gallon = Get next input

//displaying cost for 10 miles

Put DrivingCost(10,miles_per_gallon,dollars_per_gallon) to output

//printing a blank space

Put " " to output

//displaying cost for 50 miles

Put DrivingCost(50,miles_per_gallon,dollars_per_gallon) to output

Put " " to output

//displaying cost for 400 miles

Put DrivingCost(400,miles_per_gallon,dollars_per_gallon) to output

You might be interested in
Header and footer elements such as worksheet name, current date, and time are _____ elements, they change as your worksheet does
mario62 [17]
<span>Header and footer elements such as worksheet name, current date, and time are dynamic elements, they change as your worksheet does. Because the information they </span><span>contain ( page number, date,) changes that's why they are dynamic. Otherwise if the information was fixed, they would be static elements.</span>
7 0
4 years ago
dash is a set of communication standard using for transferring file information between computers in a network​
8090 [49]

Answer:

protocol

Explanation:

hope this helps.

4 0
3 years ago
A powerpoint ________ is a set of unified design elements.
natka813 [3]
<span>Within the elements of design, the set of elements of unified designs among them is called corporate because they create unity of identities of elements forming a set of equality of profiles and identities. Corporate is associated and collective to form equal elements and create a unit in the design.</span>
7 0
4 years ago
If someone said to you, “Pseudocode is a waste of time! It’s just more work because you end up writing the same program twice,”
myrzilka [38]

Answer:

It allows the designer to focus on main logic without being distracted by programming languages syntax.

* Since it is language independent, it can be translated to any computer language code.

* It allows designer to express logic in plain natural language.

* It is easier to write actual code using pseudocode.

* Unlike algorithms, pseudocodes are concise so pseudocodes are more readable and easier to modify.

Explanation:

8 0
3 years ago
Which pickaxe in minecraft to use?
Law Incorporation [45]

Answer:

Diamond pickaxe with efficiency 3

Explanation: It will mine quicker and you can just get unbreaking

6 0
3 years ago
Other questions:
  • When you set the position property for a block element to fixed, the element
    5·1 answer
  • After you enter the details for the first selected recipient in the New Address List dialog box, click _______ to add another re
    9·1 answer
  • Should I Buy a 2070 super or 2060 super
    6·1 answer
  • What can cause a Lenovo computer to be very slow right after after turning it on?
    14·1 answer
  • I used the app and my answers were still wrong??????how
    8·2 answers
  • Mobile computing is growing in importance each and every day, and the IT manager must take that into account. Do some web resear
    14·1 answer
  • Who plays xbox one offline and knows some multiplayer games that can be played offline.
    15·2 answers
  • PLEASE HELP ME!!! I REALLY NEED YOU TO HELP ME NOW!!!! THANKS!
    6·1 answer
  • Alfred works in the human resources department, and he uses a management information system to find applicants' résumés on the w
    7·1 answer
  • If userNum1 is less than 0, put "userNum1 is negative.\n" to output. If userNum2 is greater than 10, assign userNum2 with 0. Els
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!