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
olga nikolaevna [1]
3 years ago
14

2.27 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as

input, and output the gas 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);
Computers and Technology
2 answers:
exis [7]3 years ago
5 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:

leonid [27]3 years ago
3 0

Answer:

<em>Java</em>

//////////////////////////////////////////////////////////////////////////

import java.util.Scanner;

public class MyClass {

   public static void main(String args[]) {

     double miles_gallon, gas_gallon;

     ////////////////////////////////////////////////

     System.out.print("Enter miles per gallon: ");

     Scanner myObj = new Scanner(System.in);

     miles_gallon = myObj.nextDouble();

     

     System.out.print("Enter gas dollars per gallon: ");

     gas_gallon = myObj.nextDouble();

     

     System.out.println();

     ////////////////////////////////////////////////

     double twenty_miles = 20/miles_gallon*gas_gallon;

     System.out.printf("Gas cost for 20 miles: $%.2f%n%n", twenty_miles);

     

     double seventy_five_miles = 75/miles_gallon*gas_gallon;

     System.out.printf("Gas cost for 75 miles: $%.2f%n%n", seventy_five_miles);

     

     double five_hundered_miles = 500/miles_gallon*gas_gallon;

     System.out.printf("Gas cost for 500 miles: $%.2f", five_hundered_miles);

   }

}

You might be interested in
Which of the following documents specifies the uptime guarantee of a web server?A. Due processB. Due diligenceC. Scope of workD.
Harrizon [31]

Answer: D) Service Level Agreement.

Explanation: A service Level Agreement, also known by the acronym SLA, is a written agreement between a service provider and its customer in order to set the agreed level for the quality of such service. The SLA is a tool that helps both parties reach a consensus in terms of the level of service quality, in aspects such as response time, time availability, available documentation, personnel assigned to the service, among others.

6 0
3 years ago
░░░░░░░░██████████████████
ELEN [110]

OMG YUHHH

( Also I need one more brainliset until I get expert )

7 0
3 years ago
Describe the necessary Java commands to create a Java program for creating a lottery program using arrays and methods.
netineya [11]
I think each lottery ticket will cost £5 each so you would count in 5s till you reach the amount of tickets to get the answer which is £25
5 0
2 years ago
Read 2 more answers
Jayden wants to take a current theme but just change a little bit of it. Complete the steps to help Jayden.
Sindrei [870]

Answer:The theme can be automatically changed via the default settings

Explanation:

4 0
3 years ago
Hi guy how do i make money in app cuz im desperate for 1 right now​
Margarita [4]

Answer:

we need context

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • What are some ways social media networks make money from users
    10·1 answer
  • Teachers in most school districts are paid on a schedule that provides a salary based on their number of years of teaching exper
    10·1 answer
  • What is alphabet symmetry
    12·2 answers
  • What port does the DarkComet malware listen on?
    15·1 answer
  • The scope of a variable declared within a for() loop is:
    6·1 answer
  • How do you think engel would feel about computers information systems and the internet?
    14·2 answers
  • The northern and southern light occur when this interacts with the earths magnetic field.
    11·1 answer
  • How is an orthographic drawing similar or different from an isometric drawing
    12·1 answer
  • Which of the following is not a concern that has come out of the widespread adoption of the Internet?
    7·1 answer
  • Java Eclipse homework. I need help coding this|
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!