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
raketka [301]
3 years ago
6

Develop a Java application that provides program output in a logical manner and incorporates appropriate data types. Similar to

zyBooks examples in Chapter 2, your program should prompt a user to enter a car brand, model, year, starting odometer reading, ending odometer reading, and gallons used. The output should include this information along with the estimated miles per gallon consumed by the vehicle in the format MPG: your calculation. Print each on separate lines with the appropriate labels (example, MPG: 25) Submit your source code and screenshots of the application executing with output in a single document.
Computers and Technology
1 answer:
AURORKA [14]3 years ago
7 0

Answer:

A java application was designed to provide a program output in a logical manner and incorporates appropriate data types.

Explanation:

Solution

<em>Program:</em>

import java.util.Scanner;

public class Test {

  public static void main(String[] args) {

      //for taking console input

      Scanner sc = new Scanner(System.in);      

      //varibles for holding the values

      String brand, model;

      int year, startOdo, endOdo;

      double gallons, mpg;        

      //taking user inputs

      System.out.print("Enter Car Brand: "); brand = sc.nextLine();

      System.out.print("Enter Car Model: "); model = sc.nextLine();

      System.out.print("Enter Car Year: "); year = sc.nextInt(); sc.nextLine();

      System.out.print("Enter Starting Odometer reading: "); startOdo = sc.nextInt(); sc.nextLine();

      System.out.print("Enter Ending Odometer reading: "); endOdo = sc.nextInt(); sc.nextLine();

      System.out.print("Enter gallons used: "); gallons = sc.nextDouble(); sc.nextLine();        

      //calculating the mpg by dividing the total distance with fuel used

      mpg = (endOdo - startOdo) / gallons;      

      //showing the output

      System.out.println("\n*********Car Details*********");

      System.out.println("Brand: "+brand);

      System.out.println("Model: "+model);

      System.out.println("Year: "+year);

      System.out.println("Starting Odometer: "+startOdo);

      System.out.println("End Odometer: "+endOdo);

      System.out.println("Gallons Used: "+gallons);

      System.out.printf("MPG: %.2f",mpg);    

      sc.close();

}

}

You might be interested in
In an inspection, usually the first thing an inspector will want to see is:
pshichka [43]

Answer:

Your records and paperwork

5 0
3 years ago
Read 2 more answers
6. Larger Than n In a program, write a function that accepts two arguments: a list, and a number n. Assume that the list contain
Reika [66]

Answer:

The solution code is written in Python

  1. def largerThanN(myList, n):
  2.    output = ""
  3.    for x in myList:
  4.        if(x > n):
  5.            output += str(x) + " "
  6.    
  7.    print(output)
  8. l = [5, 12, 11, 4, 56, 32]
  9. n = 15
  10. largerThanN(l, n)

Explanation:

Firstly, create a function largerThanN that accepts two arguments, a list (myList) and a number (n) (Line 1).

Next, create a output variable to hold the string of numbers in the list that are greater than the input number n (Line 2).

Create a for loop to traverse through each number in the list and then check if the current x is bigger than n. If so concatenate the x to output string along with a single space " " (Line 4 -6)

After the loop, print the output string (Line 8)

We test the function by using a sample list and n = 15 (Line 10 - 12). The program will display 56 32 .

6 0
3 years ago
When you open a stream for both reading and writing files, what must you always remember to do at the end?
Leona [35]

Answer:

When you open a stream for both reading and writing you must always remember to close the stream.

Explanation:

There are three basic steps to follow to read and write data from stream.

Steps to read data from the stream

1) Open the stream

2) Read the data from the stream

3) Close the stream

Step to write data to the stream

1) Open the stream

2) Write the data to the stream

3) Close the stream

6 0
4 years ago
The ArrayList class ____ method returns the current ArrayList size.
timurjin [86]

Answer:

b. size

Explanation:

We can use the size() method of java.util.ArrayList to determine the size of an  ArrayList in Java. The size() method of the ArrayList class returns an integer which is equal to the number of elements present in the ArrayList.

Below is an example code to illustrate the use of the size() method of the ArrayList:-

     ArrayList<Integer> aList = new ArrayList<Integer>(5);

      aList.add(25);

     aList.add(2);

     aList.add(5);

     aList.add(22);

     System.out.println("Size of the array list: " + aList.size());

This will print the size of the array list as 4 since we've added four numbers into the array list.

3 0
4 years ago
Relatively simple CRUD (create, read, update, delete) web applications development can be facilitated with: _________.
Talja [164]

Answer:

c. Web Application Frameworks

Explanation:

Web Application Frameworks is a form of a software framework that is made to perform support for the building of web applications such as web services, web resources, and web APIs. Web frameworks.

Also, Web Application Frameworks automatically perform the function of primary activities carried out in web development such as create, read, update, delete.

Hence, in this case, the correct answer is Web Application Framework.

5 0
3 years ago
Other questions:
  • What do you think is the most effective way to ensure that code adheres to good coding standards? (1 correct answer)
    5·2 answers
  • The largest distribution of software cost will be when in the programs life cycle?
    12·1 answer
  • _______is the equal distribution of visual weight on either side of an imaginary axis through the center of a design. A building
    6·2 answers
  • What’s the most popular operating system
    9·2 answers
  • Which function in the plane manager allows you to create a new plane where both x and y axes are perpendicular to the line selec
    14·1 answer
  • PLZ ANSWER THESE QUESTIONS FOR 30 POINTS AND BRAINLIEST!
    9·1 answer
  • Justice wrote a program and forgot to put the steps in the correct order. Which step does she need to review?
    5·2 answers
  • Select the correct answer.
    14·1 answer
  • Javier downloads an illustration from an online Image library and modifies it for his purposes. The illustration he downloads is
    12·1 answer
  • compare the two methods of creating table in ms access ( Datasheet view and Design view) which one wouldyou prefer to use to rec
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!