Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3) Write a test application named Exam Test of options as shown in the sample output Choice 1: Ask the user to enter the medici
3) Write a test application named Exam Test of options as shown in the sample output Choice 1: Ask the user to enter the medici method returns false, display an error mes Choice 2: Call method print Choice 3: Ask the user to enter the Medici the result Choice 4: Call method sumItems and pri Choice 5: Call method average and print the result. Choice 6: Exit the program. Sample Output Please enter the pharmacy name Royal pharmacy Choose: 1. Add a Medicine 2. Print all Medicines 3. Find stack size 4. Sum of items 5. Find average 6. Exit 1 Enter the medicine name: Panadol Enter the total items: 5 Choose: 1. Add a Medicine 2. Print all Medicines 3. Find stack size 4. Sum of items 5. Find average 6. Exit 1 Enter the medicine name: Augmantine Enter the total items: 10 Choose: 1. Add a Medicine 2. Print all Medicines 3. Find stack size 4. Sum of items 5. Find average 6. Exit 2) class PharmacyStack that includes the following instance variables: private Medicine top; private String pharmacyName; private int numOfOrder; The class should have the following methods: A constructor that initializes the market name pharmacyName and sets num OfOrder to 0. public boolean push(String name, int items) Modify the given push method to increment numOfOrder by 1, creates a Medicine using numOfOrder as the medID and adds a Medicine in the stack. public void print() The method is given in the attached file. Do not make any changes to the method. private void push() The method is given in the attached file. Do not make any changes to the method. public Medicine popo The method is given in the attached file. Do not make any changes to the method. public int stackSize() Counts how many medicines are in stack. Returns the count. public int sumItems() Returns the sum of the totalItems in the stack. public double average() Calculates the average of the totalItems in the stack and returns its value. 3) Write a test application named Exam Test of options as shown in the sample output Choice 1: Ask the user to enter the medici method returns false, display an error mes Choice 2: Call method print Choice 3: Ask the user to enter the Medici the result Choice 4: Call method sumItems and pri Choice 5: Call method average and print the result. Choice 6: Exit the program. Sample Output Please enter the pharmacy name Royal pharmacy Choose: 1. Add a Medicine 2. Print all Medicines 3. Find stack size 4. Sum of items 5. Find average 6. Exit 1 Enter the medicine name: Panadol Enter the total items: 5 Choose: 1. Add a Medicine 2. Print all Medicines 3. Find stack size 4. Sum of items 5. Find average 6. Exit 1 Enter the medicine name: Augmantine Enter the total items: 10 Choose: 1. Add a Medicine 2. Print all Medicines 3. Find stack size 4. Sum of items 5. Find average 6. Exit 2) class PharmacyStack that includes the following instance variables: private Medicine top; private String pharmacyName; private int numOfOrder; The class should have the following methods: A constructor that initializes the market name pharmacyName and sets num OfOrder to 0. public boolean push(String name, int items) Modify the given push method to increment numOfOrder by 1, creates a Medicine using numOfOrder as the medID and adds a Medicine in the stack. public void print() The method is given in the attached file. Do not make any changes to the method. private void push() The method is given in the attached file. Do not make any changes to the method. public Medicine popo The method is given in the attached file. Do not make any changes to the method. public int stackSize() Counts how many medicines are in stack. Returns the count. public int sumItems() Returns the sum of the totalItems in the stack. public double average() Calculates the average of the totalItems in the stack and returns its value
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