Question
Please help! Java. I do not know what to do with the CookieProgram.java. I finished MasterOrder.java and CookieOrder.java. Download CookieProgram.java and Orders.txt.The text file contains
Please help! Java. I do not know what to do with the CookieProgram.java. I finished MasterOrder.java and CookieOrder.java.
Download CookieProgram.java and Orders.txt.The text file contains the information for the cookie orders to be stored in the master order. Create a MasterOrder object and then read in the data from the text file to fill it with CookieOrder objects. The Scanner object fileInput has already been created for you to use. Your program should then output the initial master order and the total number of boxes it contains using the getTotalBoxes method. Then ask the user which variety they would like to remove from the order and use the removeVariety method to update the master order. Finally, display the updated master order.
Here is the MasterOrder.java
import java.util.*; public class MasterOrder{ private ArrayList
}
}
Here is the CookieOrder.java
public class CookieOrder{ private String variety; private int numBoxes; public CookieOrder(String v, int n){ variety=v; numBoxes=n; } public String getVariety(){ return variety; } public int getnumBoxes(){ return numBoxes; } public String toString(){ return numBoxes+"of"+variety; } }
Here is the CookieProgram.java
import java.util.*; import java.io.*; public class CookieProgram{ public static void main(String[] args) throws IOException{ Scanner fileInput = new Scanner(new FileReader("orders.txt")); ArrayList
}
}
Here is the order.txt
4 Tagalongs 2 Tagalongs 2 Samoas 3 Trefoils 3 Do-si-dos 2 Caramel Chocolate Chip 5 Thin Mints 2 Thin Mints 7 Samoas 2 Trefoils 2 Do-si-dos 3 Thin Mints 3 Tagalongs 5 Do-si-dos 4 Trefoils 2 Thin Mints
Example output;
Initial Master Order: [4 boxes of Tagalongs, 2 boxes of Tagalongs, 2 boxes of Samoas, 3 boxes of Trefoils, 3 boxes of Do-si-dos, 2 boxes of Caramel Chocolate Chip, 5 boxes of Thin Mints, 2 boxes of Thin Mints, 7 boxes of Samoas, 2 boxes of Trefoils, 2 boxes of Do-si-dos, 3 boxes of Thin Mints, 3 boxes of Tagalongs, 5 boxes of Do-si-dos, 4 boxes of Trefoils, 2 boxes of Thin Mints] Total Boxes in the Order: 51 What variety would you like to remove? Trefoils 9 boxes of Trefoils were removed Here is the updated Master Order: [4 boxes of Tagalongs, 2 boxes of Tagalongs, 2 boxes of Samoas, 3 boxes of Do-si-dos, 2 boxes of Caramel Chocolate Chip, 5 boxes of Thin Mints, 2 boxes of Thin Mints, 7 boxes of Samoas, 2 boxes of Do-si-dos, 3 boxes of Thin Mints, 3 boxes of Tagalongs, 5 boxes of Do-si-dos, 2 boxes of Thin Mints]
Can you please give me some tips about how to understand the assignment faster? Like when I look at the assignment, I know what code should I use to write the program.
Thank you!
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