how can i get user input with this code of how many cup cakes each stand sold
Fantastic news! We've Found the answer you've been seeking!
Question:
how can i get user input with this code of how many cup cakes each stand sold
public class Main { //This is a instance variables int ID; int soldedCupCakes; static int totalCupCakes; public Main (int ID, int soldedCupCakes) { this.ID = ID; this.soldedCupCakes = soldedCupCakes; totalCupCakes = totalCupCakes + soldedCupCakes; } // This is a method just solded method public void JustSolded() { // increment soldedCupCakes soldedCupCakes++; //This is a increment totalCupCakes totalCupCakes++; } // This is a return soldedCupCakes public int numberOfCupCakes() { return soldedCupCakes; } //This is a return totalCupCakes public static int totalNumberOfCupCakesSolded() { return totalCupCakes; } @Override public String toString() { return "Bakery stand # " + ID + " has solded " + soldedCupCakes + ", All stands together solded " + totalCupCakes + " cupcakes."; } public static void main(String[] args) { // create BakeryStand objects Main bakeryStand1 = new Main (1, 3); // call JustSolded bakeryStand1.JustSolded(); Main bakeryStand2 = new Main (2, 6); // print details using toString method System.out.println(bakeryStand1); System.out.println(bakeryStand2); } }
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date: