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]
2 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]2 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]2 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
Write a program that prompts the user to enter the number of students and each student's name and score, and finally displays th
kiruha [24]

Answer:

  see attachment

Explanation:

You have not specified the language, or the details of the I/O form or prompts. Here is a program that does that, written in Wolfram language (the language of Mathematica).

It prompts separately for student name and student score. The minimum score is presumed to be higher than -99999. If only one student name is entered, the second output is that score with no name listed. There is no error checking.

We have elected to keep a list only of the two two scores, and to sort that list again each time a new entry is made.

__

The attachment shows the output of the program below the program listing.

7 0
3 years ago
A systemic approach to creating and ensuring channel fluidity in the flows of goods and services through shared information, com
likoan [24]

Answer:

Explanation:

The one which best describes it is Co-opetition. Co-opetition often takes place when companies which are in the same market work put aside their differences and work together in the gathering of knowledge and research of new products, but they still compete for market-share of their products and in the application of the joint knowledge created.

7 0
3 years ago
Read 2 more answers
Write a note on secondary storage​
12345 [234]
Secondary storage refers to storage devices and media that are not constantly accessible by a computer system. Examples include external hard drives, portable flash drives, CDs, and DVDs.
good luck
4 0
3 years ago
Why isn’t Brainly working? It isn’t letting me watch an ad what do I do to fix it?
Mazyrski [523]

Answer:

reload the page or exit the page and log back on

Explanation:

8 0
2 years ago
Jack is part of the software quality assurance team in a company. Which activity should Jack perform as a part of software quali
gizmo_the_mogwai [7]

Answer:

C - testing

Explanation:

quality assurance is another name for verifying something. so when you verify software, you test the software.

3 0
3 years ago
Other questions:
  • What is a benefit of peer-to-peer networking?
    14·2 answers
  • Which windows tool can you use to find out if the hard drive is slowing down windows performance?
    9·1 answer
  • A quick boot allows you to do what?
    7·2 answers
  • Mary from sales is asking about the plan to implement Salesforce.com's application. You explain to her that you are in the proce
    9·1 answer
  • What operating system is an open source program
    15·1 answer
  • Do you think communities or countries can survive without the internet?why or why not?​
    11·1 answer
  • Does anyone play call of duty cold war campaign. I have a question, please help me.
    8·2 answers
  • Create the HTML code for this
    14·1 answer
  • What is the result of the following code?<br><br> x=7//2+10%2**4<br><br> print(x)
    15·1 answer
  • which of the following is acomputer program that detects, prevents. and takes action sto deactivate or remove malicious programm
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!