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
Burka [1]
2 years ago
7

Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g

as cost for 20 miles, 75 miles, and 500 miles. Output each floating-point value with two digits after the decimal point, which can be achieved as follows: System.out.printf("%.2f", yourValue); The output ends with a newline.
Computers and Technology
2 answers:
Tatiana [17]2 years ago
4 0

Answer:

const double gasDollarPerGallon = 20 ;

float calCost( double milesPerGallon ) {

   double costPerGallon = milesPerGallon / gasDollarPerGallon;

   System.out.printf ("%.2f/n", &costPerGallon);

int main ( ) {

   scanf ("%2f", &gasDollarPerGallon) ;

   calCost( 20 );

   calCost( 75 );

   calCost( 500 );

Explanation:

The C source code above gets the user input of the gas dollar per gallon from the command prompt and divides the miles per gallon variable in the function call to get the cost of gas for the range of miles. It is also print out as a double with two places.

kiruha [24]2 years ago
4 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
Calculate the resistance of an unknown resistor in a circuit with 30 volts and 6 amps. The formula is R = V/I.
arsen [322]
The answer is 5 ohms
7 0
2 years ago
What is the capture of transaction and event information using technology to (1) process the information according to defined bu
Tanya [424]

Answer:

OLTP(Online transaction processing)  is the correct answer.

Explanation:

It is the database application that is used to catching the transection and that data or information which is related to the technology for the purpose of.

  • Process that data and information which is related to the following rules of the business or company.
  • It stores the data or information related to the online transaction.
  • It also helps to modify the current data or information for the new data or information.
6 0
3 years ago
How does electricity work in phones?
kati45 [8]
Great Question! So the plug will go into the wall and electricity will hit the cord and power through the cord into the charger (Cordless) Now if you talking mobile phones such as iPhones. The battery powers wire and hardware to power your little mobile phone! Hope this helps.
8 0
3 years ago
To prevent class objects from being copied or assigned, you can:
Travka [436]

Answer:

The correct answer to the following question is option 4.

Explanation:

The private class does not mean that the package-private, it means that no other class can see its members.  

It is used in creating the building blocks which is implementing the internal functionality that you don't want to visible to the other projects using the library.

We can use private constructor to ensure that more than one object cannot be created at the time.

6 0
2 years ago
Which command displays the status of the ipsec installation?
Alexandra [31]
Character command shows the status.
8 0
2 years ago
Other questions:
  • What effects will the different types of lighting produce on mountains?
    15·1 answer
  • These are questions from my Computer/Customer Support Class
    6·1 answer
  • Which of the following represents inbound logistics for a bookstore
    13·1 answer
  • Match these items. 1 . Naturalization Act stated that a foreigner had to live in the United States fourteen years to become a ci
    5·1 answer
  • No production Web application, whether it resides inside or outside of the firewall, should be implemented without:
    6·1 answer
  • What is the by stander effect
    9·1 answer
  • Write a program in qbasic to accept a character and check it is vowel or consonant​
    14·1 answer
  • Commercial technical data and commercial software:_________.
    11·1 answer
  • What is the impact of VR on Educational Learning rather than games?​
    13·1 answer
  • Which of the following screen elements is a horizontal bar that displays at the
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!