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
You can set a ________, which is automatically displayed in a field unless the user enters something different.
Wittaler [7]

Answer:

Place holder

Explanation:

In computer programming, placeholder is a word, character or series of characters that is used to take up the space until the time when the space is actually needed. It is widely used in the sign up or login forms for web and mobile applications. For example, First Name, Last Name etc.

A programmer might have an idea that he will require this number of characters or values but he don't knows what the input will be, that’s why he uses the place holder.

Hope it helps!

6 0
3 years ago
To improve performance on an iSCSI SAN, a network technician configured an MTU value of 9000 on the Ethernet LAN. What did the t
nevsk [136]

Answer:

Jumbo frames

Explanation:

Ethernet frames having a payload size above 1500 bytes are called Jumbo frames. The maximum MTU value set by the IEEE 802.3 is 1500 bytes, but jumbo frames have sizes up to a maximum of 9000 bytes, hence they do not meet the standards of IEEE 802.3. They are used in local area networks that can transmit data at high rates of 1 gigabits per second.

6 0
3 years ago
Write a program that prints the U.S. presidential election years from 1792 to present day, knowing that such elections occur eve
Naddika [18.5K]
Year = 1972
current year = 2021

while year <= current year:
print (year)
year = year + 4
8 0
2 years ago
[20 pts] Write the function rectangle(perimeter, area), which takes two positive integers, perimeter and area. It returns an int
MrRissso [65]

Hi, you haven't provided the programing language in which you need the code, I'll explain how to do it using Python, and you can follow the same logic to make a program in the programing language that you need.

Answer:

import math

def rectangle(perimeter, area):

   l1_1 = (perimeter+math.sqrt((perimeter**2)-(16*area)))/4

   l1_2 = (perimeter-math.sqrt((perimeter**2)-(16*area)))/4

   l2_1 = area/l1_1

   l2_2 = area/l1_2

   print(l1_1,l2_1)

   print(l1_2,l2_2)

   if l1_1.is_integer() and l2_1.is_integer() and l1_1>0 and l2_1>0:

       return(int(max(l1_1,l2_1)))

   elif l1_2.is_integer() and l2_2.is_integer() and l1_2>0 and l2_2>0:

       return(int(max(l1_2,l2_2)))

   else:

       return(None)

Explanation:

  • We import math to make basic operations
  • We define the rectangle function that receives perimeter and area
  • We calculate one of the sides (l1_1) of the rectangle using the quadratic equation to solve 2h^2 - ph + 2a = 0
  • We calculate the second root of the quadratic equation for the same side (l1_2)
  • We calculate the second side of the rectangle using the first root on w = a/h
  • We calculate the second side of the rectangle using the second root on w= a/h
  • We verify that each component of the first result (l1_1, l2_1) is an integer (using the build-in method .is_integer) and greater than 0, if True we return the maximum value between them (using the max function) as w
  • If the first pair of sides evaluate to False we check the second root of the equation and if they meet the specification we return the max value
  • if all the if statements evaluate to false we return None to indicate that not positive or integer sides were found

7 0
2 years ago
Which technology can be used as a defense against dos and ddos syn flood attacks?
Montano1993 [528]
In terms of websites, there's a service called cloud flare which can prevent DDOS attacks in websites. Other applications you would have to look up. Hopefully this helps!
6 0
3 years ago
Other questions:
  • Disk scheduling algorithms in operating systems consider only seek distances, because Select one: a. modern disks do not disclos
    13·1 answer
  • Which aspects of a project do project makers oversee?
    12·2 answers
  • What is FireWire?
    7·2 answers
  • In Python, arrays are usually reserved for
    12·1 answer
  • Which is the best description of the laws governing IT professionals?
    5·1 answer
  • #Write a function called hide_and_seek. The function should #have no parameters and return no value; instead, when #called, it s
    7·1 answer
  • Which type of fiber-optic connector, containing one fiber-optic strand per connector, is connected by pushing the connector into
    7·1 answer
  • Which of the following behaviors does not harm a company if your employment is terminated?
    9·1 answer
  • Write a program in C/C++ to draw the following points: (0.0,0.0), (20.0,0.0), (20.0,20.0), (0.0,20.0) and (10.0,25.0). For this
    6·1 answer
  • 72. In Object Oriented Programming, a class_____ starts
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!