Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[JAVA] I am doing a practice assignment and am having trouble figuring out what to do next in the Main Class. I already finished the

[JAVA] I am doing a practice assignment and am having trouble figuring out what to do next in the Main Class. I already finished the StoreOrder class with no errors but am stuck now. I would greatly appreciate if somebody could help me out so I can see what to do and practice retyping it. Thanks in advance! The sample output is given below as well as the instructions I was given. I will paste the code I already typed below as well.

Instructions:

image text in transcribed

Sample Output:

image text in transcribed

StoreOrder class:

public class StoreOrder { private final double PENCIL_COST = .12; private final double PEN_COST = .16; private final double ERASER_COST = .22; private String companyName; private int numPencils; private int numPens; private int numErasers; public StoreOrder() { companyName = null; numPencils = 0; numPens = 0; numErasers = 0; } public StoreOrder(String companyName) { this.companyName = companyName; } public String getCompanyName() { return companyName; } public int getNumPencils() { return numPencils; } public int getNumPens() { return numPens; } public int getNumErasers() { return numErasers; } private void addPencils(int num) { num = numPencils; } private void addPens(int num) { num = numPens; } private void addErasers(int num) { num = numErasers; } public double computeCost() { return ((getNumPencils()*.12) + (getNumPens()*.16) + (getNumErasers()*.22)); } }

Main class so far:

import java.util.Scanner; public class MainStoreOrder { public static final double TAX_RATE = .075; public static final int DISCOUNT = 15; public static Scanner kb = new Scanner(System.in); public static void main(String[] args) { System.out.println("Programmed by Samuel Huegen"); System.out.print("Enter company name: "); String companyName = kb.nextLine(); } }

Once the class is working, create a Main class and a main method. The following should be declare as instance variables for the Main class public static final double TAX RATE = .075 public static final int DISCOUNT = 15; public static Scanner kbnew Scanner (System.in); The main method should produce the output given below. Is should call the following methods displayMenuGetSelection- This method displays the menu to the screen and asks the user to enter their selection. It returns a character. getValidInput - This method asks the user to type in the integer value for quantity. It makes sure that the quantity is a positive value and then returns it. determineDiscount - This method returns an integer value for the discount. A StoreOrder object is passed in to the method and the method returns the constant discount or zero, depending on whether there is a discount or not. calculateAndPrintReceipt - A StoreOrder object is passed into the method. This method calls the method to compute the cost in the class, and the determine Discount method. It computes costs and prints the receipt as shown in the output. Requirements 1. If the program does not compile, it is a zero 2. Submit the two java files to moodle by the due date. If the incorrect files are submitted it will be a zero. (Check to make sure the correct files are uploaded) 3. There should be FIVE constants: the cost of a pencil, the cost of a pen, the cost of an eraser (in the StoreOrder class) and the tax and the discount (in 4. Your output should be identical (except for your name) to the output given 5. Comments should be at the top of all files that you turn in with your name 6. You must use a switch statement in main to determine which choice the user 7. The program should compute the correct answer for all proper input. The the Main class) when the input given is typed in, this includes spacing class, etc. selected and to call the method to add to the appropriate field in the object output given does NOT test all possibilities, but the program should work for all input Words of Wisdom 1. Do NOT enter all of the program in at one time and then compile and run it 2. DO NOT WAIT UNTIL THE LAST MINUTE!!! Things come up with computers. Try to start assignments as soon as you get them. Sample Outputs DFiniahed Corpany Drdez Finiabed Company Orde DFiniahed Company Drder 1x there another cotpany order IYA): y Finiabed Company Orde 1a theze anothe company order (Y/N): y Finiabed Company Orde there another company order Finiabed Company Orde DFiniahed Company Drder Numbez of penci1a:1 Total anount due: 8-4 Finiabed Company Orde Ia there anothe: company ordns (Y/N): n Finiabed Company Orde there another company order

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

Advances In Databases And Information Systems 23rd European Conference Adbis 2019 Bled Slovenia September 8 11 2019 Proceedings Lncs 11695

Authors: Tatjana Welzer ,Johann Eder ,Vili Podgorelec ,Aida Kamisalic Latific

1st Edition

3030287297, 978-3030287290

More Books

Students also viewed these Databases questions