Question: In Java with comments, Provide default constructor, constructor that takes in gallons and cups Provide getGallon, setGallon, getCups, setCups Copy and past the code below

In Java with comments,

Provide default constructor, constructor that takes in gallons and cups

Provide getGallon, setGallon, getCups, setCups

Copy and past the code below into your project, and build from there.

public static class GallonCups {

private int gallon;

private int cups;

public String toString()

{

return gallon + " gallon(s) and " + cups + " cup(s). ";

}

}

public static void main(String[] args) {

Scanner keyboard = new Scanner (System.in);

System.out.println("Enter the number of gallon as a whole number");

int gallon1 = keyboard.nextInt();

System.out.println("Enter the number of cups as a whole number");

int cup1 = keyboard.nextInt();

GallonCups f = new GallonCups(gallon1, cup1);

System.out.println(f);

f.setGallon(4);

f.setCups(112);

System.out.println(f);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!