Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions