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
The correct order of operations is _____. brackets, exponents, division, multiplication, addition, and subtraction subtraction,
bija089 [108]

brackets, exponents, division, multiplication, addition, and subtraction

6 0
3 years ago
Read 2 more answers
Suppose you can access the caches in the local DNS servers of your department. Can you propose a way to roughly determine the We
lubasha [3.4K]

Answer:

We can periodically take a snapshot of the Domain Name System (DNS) caches in the local  Domain Name System (DNS) servers.

Explanation:

We can periodically take a snapshot of the Domain Name System (DNS) caches in the local  Domain Name System (DNS) servers. The Web server that appears most frequently in the  Domain Name System (DNS) caches is the most popular server. This is because if more users are interested in a Web server, then Domain Name System (DNS) requests for that server are more frequently sent by users. Thus, that Web server will appear in the  Domain Name System (DNS) caches more frequently.  

6 0
3 years ago
Abrupt changes in road surface or the shape of the road may indicate
Zanzabum

Answer:

D. a potential hazard

Explanation:

Abrupt changes in road surface or the shape of the road may indicate a potential hazard.

5 0
3 years ago
Read 2 more answers
Could somebody please find the bugs and amend them? This question is worth 25 Brainly points!
Andreyy89

line 4

if salary < 30000

error missing ":"

solution

if salary < 30000:

line 6

tax = salary * 0.2

error is missing identifier for tax

solution add identifier for tax on line 3

tax = 0.0

line 11

error syntax

solution is move tax = salary * 0.4 + 6000 to the right

tax = salary * 0.4 + 6000

6 0
3 years ago
A(n) ____________ is a private data network that creates secure connections over regular internet lines.
Setler79 [48]
VPN is the correct answer
5 0
3 years ago
Other questions:
  • Which port can connect you to the Internet through a telephone line?
    6·1 answer
  • Data arranged and stored in a data set
    9·1 answer
  • 1. Define a C++ function with the name evaluateBook. The function receives as one argument the name of the file to be processed
    13·1 answer
  • Please help me answer this question
    14·1 answer
  • application that will perform a lot of overwrites and deletes of data and requires the latest information to be available anytim
    8·1 answer
  • To generate a report with exact results based on specific criteria it is best to base the report on a(n) ____________________ cr
    6·1 answer
  • How are switches indirectly involved in ARP poisoning?
    6·1 answer
  • Final one bit l y links are a virus that will corrupt your files do not go on it
    15·2 answers
  • Need help:(!!!! I’ll mark brainliest if correct
    5·1 answer
  • What is computer fundamental ?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!