Part A: Write the QuartsToGallons Java class that declares a named constant to hold the number of quarts in a gallon (4). Also declare a variable to represent the number of quarts needed for a painting job, and assign an appropriate value—for example, 18. Compute and display the number of gallons and quarts needed for the job. Display explanatory text with the values, for example:

Respuesta :

ijeggs

Complete Question:

Part A: Write the QuartsToGallons Java class that declares a named constant to hold the number of quarts in a gallon (4). Also declare a variable to represent the number of quarts needed for a painting job, and assign an appropriate value—for example, 18. Compute and display the number of gallons and quarts needed for the job. Display explanatory text with the values, for example:

A job that needs 18 quarts requires 4 gallons plus 2 quarts.

Answer:

The complete code is given in the explanation section

Explanation:

import java.util.Scanner;

public class QuartsToGallons {

   public static void main(String[] args) {

       final int NUMBER_OF_QUARTS = 4;

       int numJobs;

        Scanner in = new Scanner(System.in);

       System.out.println("Enter number of paint in quarts for the painting job?");

       numJobs = in.nextInt();

       int numGallons = numJobs / NUMBER_OF_QUARTS;

       int numQuarts = numJobs % NUMBER_OF_QUARTS;

       System.out.println("The painting Job of " + numJobs + " quarts requires "

               + numGallons + " gallons and " + numQuarts + " quarts of paint.");

   }

}