Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

DATABASE Administrator Make A Difference

Authors: Mohciine Elmourabit

1st Edition

B0CGM7XG75, 978-1722657802

More Books

Students also viewed these Databases questions

Question

The models used to analyse different national cultures.

Answered: 1 week ago

Question

The nature of the issues associated with expatriate employment.

Answered: 1 week ago