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
Define operating system?explain the types of operating system on the basis of use.​
GalinKa [24]

Answer:

An operating system is a software that helps the any computers basic needs or functions.  For example, the windows on a computer is a operating system.

Explanation:

4 0
2 years ago
What is a table in excel
tekilochka [14]
A table in excel is responsible for keeping track of numerical data.

Meaning information in the form of numbers.
8 0
3 years ago
Read 2 more answers
Pls answer will give brainlest dont answer if you dont know Upload your 300-word essay containing the following: the definition
Rainbow [258]

Answer: oh hello human :) also PLEASE DONT KILL ME I’m answering this because the question was already answered already on another post

6 0
2 years ago
Q10: Putting it all together (0.75 points) Here, we'll update the values in dictionary, storing the output in a dictionary calle
Molodets [167]

Answer:

# Code in Python

dictionary={'A':1,'B':2,'C':3,'D':4}

other_dictionary={}

for keys in dictionary:

if dictionary[keys]&1==1:

temp=dictionary[keys]*dictionary[keys]-10*10

other_dictionary[keys]=temp

else:

other_dictionary[keys]=dictionary[keys]

print(other_dictionary)  

assert other_dictionary

Explanation:

  • Initialize a sample example dictionary  and other_dictionary.
  • Do a binary comparision for checking odd number .
  • Update the the value stored in the dictionary to store the squared difference of the original value and '10'.
  • For even: store the original value (from dictionary).
4 0
3 years ago
Write the code to produce a for loop that counts down from 20 to 0 by 2’s and prints the number each time it goes through the lo
yulyashka [42]

Explanation:

Count-controlled for loop (Three-expression for loop)

This is by far the most common type. This statement is the one used by C. The header of this kind of for loop consists of a three-parameter loop control expression. Generally it has the form:

for (A; Z; I)

A is the initialisation part, Z determines a termination expression and I is the counting expression, where the loop variable is incremented or dcremented. An example of this kind of loop is the for-loop of the programming language C:

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

This kind of for loop is not implemented in Python!

Numeric Ranges

This kind of for loop is a simplification of the previous kind. It's a counting or enumerating loop. Starting with a start value and counting up to an end value, like for i = 1 to 100

Python doesn't use this either.

Vectorized for loops

They behave as if all iterations are executed in parallel. This means, for example, that all expressions on the right side of assignment statements get evaluated before the assignments.

Iterator-based for loop

Finally, we come to the one used by Python. This kind of a for loop iterates over an enumeration of a set of items. It is usually characterized by the use of an implicit or explicit iterator. In each iteration step a loop variable is set to a value in a sequence or other data collection. This kind of for loop is known in most Unix and Linux shells and it is the one which is implemented in Python.

Example of a simple for loop in Python:

>>> languages = ["C", "C++", "Perl", "Python"]  

>>> for x in languages:

...     print(x)

...  

C

C++

Perl

Python

>>>

3 0
2 years ago
Other questions:
  • What is a computer??????????????????????????????????????????????????????????
    12·2 answers
  • ____ deals with ensuring that data is protected against unauthorized access, and if the data are accessed by an authorized user,
    10·1 answer
  • In this exercise, you are given a word or phrase and you need to return that word or phrase with the word ‘like’ in front of it.
    5·1 answer
  • Your project must satisfy the following requirements:
    7·1 answer
  • Which of these computers was marketed as a computer/game machine?
    15·2 answers
  • What are the different between Facebook and LinkedIn
    15·2 answers
  • A user reports his or her computer is slow to boot. You check the boot order and determine that the computer is checking the C d
    12·1 answer
  • Im lonnnelllly........................who want to date
    11·1 answer
  • Software licensed as proprietary
    11·2 answers
  • You have received an update package for a critical application you are running on a virtual machine. You have been told to insta
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!