Question
public static class GallonCups { private int gallon; private int cups; //provide default constructor, constructor that takes in gallons and cups in java //getGallon, setGallon,
public static class GallonCups {
private int gallon;
private int cups;
//provide default constructor, constructor that takes in gallons and cups
in java
//getGallon, setGallon, getCups, setCups
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);
}
My code down here
public class GallonCups1 {
/** * @param args the command line arguments */ public static class GallonCups { private int gallon; private int cups; public GallonCups() { } public GallonCups(int g, int c) { while(cups >= 16) } public String toString(){ return gallon +" gallon(s)and"+ cups + " cup(s)."; } public int getCups() { return cups; } public int getGallons() { return gallon; } public void setCups(int c) { cups = c; } public void setGallon(int g) { gallon = g; } 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); } } }
//provide default constructor, constructor that takes in gallons and cups
//getGallon, setGallon, getCups, setCups
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started