In: Computer Science
Java
Write a program that declares a constant named QUARTS_IN_GALLON which holds the number of quarts in a gallon (4). Also declare a variable named quartsNeeded to represent the number of quarts needed for a painting job, and assign an appropriate value. 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. When submitting the program for testing/grading, assign the value 18 to quartsNeeded.
ANSWER:-
import java.util.*;
public class Painting
{
   public static void main (String[] args)
   {
       int QUARTS_IN_GALLON=4;
       Scanner sc=new
Scanner(System.in);
       System.out.println("enter quarts
needed for painting : ");
       int
quartsNeeded=sc.nextInt();
       int
quarts=quartsNeeded%QUARTS_IN_GALLON;
       int
gallons=quartsNeeded/QUARTS_IN_GALLON;
       if(quarts!=0)
       System.out.println("A job that
needs "+quartsNeeded+" quarts requires "+gallons+" gallons plus
"+quarts);
   else
   System.out.println("A job that needs "+quartsNeeded+"
quarts requires "+gallons+" gallons");
      
   }
}
// OUTPUT:

// If any doubt please comment