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
Pachacha [2.7K]
3 years ago
11

Write a program that asks the user to input

Computers and Technology
1 answer:
Savatey [412]3 years ago
5 0

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

Scanner input = new Scanner(System.in);

       System.out.println("Please Enter the number of fuel gallons in the car's tank: ");

       int numGallons = input.nextInt();

       System.out.print("What is the fuel efficiency of your car in miles/gallon ");

       double fuelEffi = input.nextDouble();

       System.out.print("How much is the price per gallon: ");

       double price = input.nextDouble();

       double milesCanGo = fuelEffi*numGallons;

       double numOfGallons100Miles = 100/fuelEffi;

       System.out.println("The cost per 100 miles is "+numOfGallons100Miles*price);

       System.out.println("Your car can go as far as "+milesCanGo+" miles with the current fuel " +

               "in your tank");

   }

}

Explanation:

Using Java programming language;

  1. Import the Scanner class to receive user input
  2. Prompt user to input numofGallons, fuelEfficiency and pricePerGallon
  3. Calculate the miles the car can go with the formula milesCanGo = numofGallons X fuelEfficiency
  4. Calculate the number of gallons for 100 miles distance (100/fuelEfficiency)
  5. The cost of driving 100 miles is (100/fuelEfficiency)*pricePerGallon
  6. Output cost for 100 miles and how far the car can go.
You might be interested in
How to play Drinkopoly game?
professor190 [17]
Answer:
Never heard of that lol
3 0
3 years ago
Given the code that reads a list of integers, complete the number_guess() function, which should choose a random number between
Cerrena [4.2K]

Answer:

see explaination

Explanation:

import random

def number_guess(num):

n = random.randint(1, 100)

if num < n:

print(num, "is too low. Random number was " + str(n) + ".")

elif num > n:

print(num, "is too high. Random number was " + str(n) + ".")

else:

print(num, "is correct!")

if __name__ == '__main__':

# Use the seed 900 to get the same pseudo random numbers every time

random.seed(900)

# Convert the string tokens into integers

user_input = input()

tokens = user_input.split()

for token in tokens:

num = int(token)

number_guess(num)

5 0
4 years ago
What is the advantage of learning through story compared to learning through personal experience?
Inessa [10]

Answer:

Personal Experience

Explanation:

If a story is based on a personal experience then yes, the two doesn't matter. <em>However</em>, usually learning through personal experience is better because you learn firsthand while stories are written from a different perspective.

6 0
3 years ago
Read 2 more answers
Consider sending a 2400-byte datagram into a link that has an mtu of 700 bytes. suppose the original datagram is stamped with th
Feliz [49]

Explanation:

Let, DG is the datagram so, DG= 2400.

Let, FV is the Value of Fragment and F is the Flag and FO is the Fragmentation Offset.

Let, M is the MTU so, M=700.

Let, IP is the IP header so, IP= 20.

Let, id is the identification number so, id=422

Required numbers of the fragment = [\frac{DG-IP}{M-IP} ]

Insert values in the formula = [\frac{2400-20}{700-20} ]

Then,        = [\frac{2380}{680} ] = [3.5]

The generated numbers of the fragment is 4

  • If FV = 1 then, bytes in data field of DG= 720-20 = 680 and id=422 and FO=0 and F=1.
  • If FV = 2 then, bytes in data field of DG= 720-20 = 680 and id=422 and FO=85(85*8=680 bytes) and F=1.
  • If FV = 3 then, bytes in data field of DG= 720-20 = 680 and id=422 and FO=170(170*8=1360 bytes) and F=1.
  • If FV = 4 then, bytes in data field of DG= 2380-3(680) = 340 and id=422 and FO=255(255*8=2040 bytes) and F=0.

3 0
3 years ago
You are given a 6x8 (6 rows, 8 columns) array of integers, x, already initialized and three integer variables: max, i and j. Wri
Aneli [31]

Answer:

The code is mentioned below.

Explanation:

This code is written in C.

Assuming that an array of 6 by 8 is already initialized and stored in a vector

x[6][8]

which will be called or referred in program by:

x [i] [j]

Alongwith the array the variables i j and max will be initialized as integers.

CODE:

int i,j,max;

max=0;

for(i=0;i<6;i++)

{

for(j=0;j<6;j++)

{

if(max>x[i][j])

max = x[i][j];

}

}

This code will check each and every entry of 6 by 8 array and place the largest value in max.

5 0
3 years ago
Other questions:
  • A Narrative Statement illustrates how your life will look when you reach a goal.
    15·2 answers
  • Whenever I go onto Google Chrome, the words are in Spanish! How can I make the words be back in English again? Please let me kno
    7·1 answer
  • Pls help! ive been looking everywhere online but I couldn't find the answer to this:
    5·1 answer
  • Explain how it is possible for a sequence of packets transmitted through a wide area network to arrive at their destination in a
    14·1 answer
  • A network monitor records the following information while recording a network connection.
    9·1 answer
  • ​if a primary key combines two or more fields, then it is called a _____.
    14·1 answer
  • The ____ aggregate function finds the largest value
    10·1 answer
  • You are comparing cryptographic solutions to implement at your organization. Which two items should you focus on when you are ev
    12·1 answer
  • Use the drop-down menus to complete the steps to share a presentation through OneDrive.
    6·1 answer
  • The profile picture that you plan to use to market your professional brand on social media networks should feature you only.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!