Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSCE 145 Program 3 Java Program: Ice-Cream Order Name: Setup 1. In Eclipse go to File/New/Java Project name it: Program3Yourlastname Yourfirstname 2. Go to File/New/Class
CSCE 145 Program 3 Java Program: Ice-Cream Order Name: Setup 1. In Eclipse go to File/New/Java Project name it: Program3Yourlastname Yourfirstname 2. Go to File/New/Class name it the exact same as the project 3. You will need a main method: public static void main(String[] args) /*your code here*/} a. Use Scanner OR JOptionPane: import java.util.Scanner; OR import javax.swing.JOptionPane; b. Show price list "Cone = $3 + $2 per extra scoop + $1 per topping" C. Ask how many cones print("How many cones?");coneCount=kb.nextInt(); i. Create array of Cone objects Cone[] cones=new Cone[coneCount); ii. Create new Cone objects cones[i]=new Cone(i);// this calls Cone code below, it will be in a loop d. Repeat each cone order & price print(cones(i);//lists all scoops, toppings, price; will be in second loop i. Print #of cones & total call static methods to access static variables, see Cone class below 4. Go to File/New/Class name this new class Cone a. Create static variables private static int totalCones=0, totalPrice=0; b. Create instance variables for private int scoop Count, topCount, conePrice, conePlace; properties of an individual cone private String [] scoopFlavors, topFlavors://just examples i. Create array for place String[] place ={"1st", "2nd"}//etc. for each 1t05, & maybe "" for no place(1cone) C. Create default constructor Cone()//initialize all instance variables, call addCone()//see below i. Create constructor for number Cone(int num){cone Place=num}//and call default constructor & methods below d. Create static methods public static void addCone()//adds 1 to totalcone to update static variables public static addTotalPrice()//adds this cone's price to totalPrice e. Create setScoops() method scoop Count=kb.nextInt();scoopFlavors=new String[]; scoopFlavors[i]=kb.next(); //orders of 1cone, no cone place needed but show scoop place if scoopCount>1 i. Overload setScoops(String place) //as above but indicate which cone, (for both use place array to show scoop place) f.Create setTops() methods /*same as scoops above but for toppings*/topCount=kb.nextInt();//etc. i. Option replace set Scoops and setTops with generic setFlavors for both, still overload g. Create setPrice() method calculate conePrice based on # of scoops & toppings, call addTotalPricel) h. Create other getters getPrice, getFlavor, getTop, and static getTotalCones, getTotalPrice i. Overwrite to String method should print # and values for scoops, flavors, topping, and price Lab 1. Let the user place ice-cream orders. Each order will have 1 to 5 cones (objects). Each cone will have 1 to 3 scoops and 0 to 2 toppings. Let user enter any String for the flavors and toppings. Use String arrays for toppings and flavors. 2. After the order is done, repeat back to the user the price of each cone and all the flavors of scoops and all the flavors of toppings for each cone. 3. Then tell the user how many total cones were ordered and the total price. 4. The Program3 class can handle new cones (you will need an array of 5 cone objects) and printing order back to user a. Handle all details of an individual cone (scoop and topping input) in Cone class 5. The use of for loops may prove helpful for getting and repeating orders (each scoop's and topping's flavor) CSCE 145 Program 3 Java Program: Ice-Cream Order Name: Setup 1. In Eclipse go to File/New/Java Project name it: Program3Yourlastname Yourfirstname 2. Go to File/New/Class name it the exact same as the project 3. You will need a main method: public static void main(String[] args) /*your code here*/} a. Use Scanner OR JOptionPane: import java.util.Scanner; OR import javax.swing.JOptionPane; b. Show price list "Cone = $3 + $2 per extra scoop + $1 per topping" C. Ask how many cones print("How many cones?");coneCount=kb.nextInt(); i. Create array of Cone objects Cone[] cones=new Cone[coneCount); ii. Create new Cone objects cones[i]=new Cone(i);// this calls Cone code below, it will be in a loop d. Repeat each cone order & price print(cones(i);//lists all scoops, toppings, price; will be in second loop i. Print #of cones & total call static methods to access static variables, see Cone class below 4. Go to File/New/Class name this new class Cone a. Create static variables private static int totalCones=0, totalPrice=0; b. Create instance variables for private int scoop Count, topCount, conePrice, conePlace; properties of an individual cone private String [] scoopFlavors, topFlavors://just examples i. Create array for place String[] place ={"1st", "2nd"}//etc. for each 1t05, & maybe "" for no place(1cone) C. Create default constructor Cone()//initialize all instance variables, call addCone()//see below i. Create constructor for number Cone(int num){cone Place=num}//and call default constructor & methods below d. Create static methods public static void addCone()//adds 1 to totalcone to update static variables public static addTotalPrice()//adds this cone's price to totalPrice e. Create setScoops() method scoop Count=kb.nextInt();scoopFlavors=new String[]; scoopFlavors[i]=kb.next(); //orders of 1cone, no cone place needed but show scoop place if scoopCount>1 i. Overload setScoops(String place) //as above but indicate which cone, (for both use place array to show scoop place) f.Create setTops() methods /*same as scoops above but for toppings*/topCount=kb.nextInt();//etc. i. Option replace set Scoops and setTops with generic setFlavors for both, still overload g. Create setPrice() method calculate conePrice based on # of scoops & toppings, call addTotalPricel) h. Create other getters getPrice, getFlavor, getTop, and static getTotalCones, getTotalPrice i. Overwrite to String method should print # and values for scoops, flavors, topping, and price Lab 1. Let the user place ice-cream orders. Each order will have 1 to 5 cones (objects). Each cone will have 1 to 3 scoops and 0 to 2 toppings. Let user enter any String for the flavors and toppings. Use String arrays for toppings and flavors. 2. After the order is done, repeat back to the user the price of each cone and all the flavors of scoops and all the flavors of toppings for each cone. 3. Then tell the user how many total cones were ordered and the total price. 4. The Program3 class can handle new cones (you will need an array of 5 cone objects) and printing order back to user a. Handle all details of an individual cone (scoop and topping input) in Cone class 5. The use of for loops may prove helpful for getting and repeating orders (each scoop's and topping's flavor)
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