Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in java will like ogram Specifications Write a SelfPaykiosk class to support basic operations such as scan item, cancel transaction, checkout, and make ayment. SelfPaykioskjava

in java will like image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
ogram Specifications Write a SelfPaykiosk class to support basic operations such as scan item, cancel transaction, checkout, and make ayment. SelfPaykioskjava is provided with method stubs. Follow each step to gradually complete all methods. Lote: This program is designed for incremental development. Complete each step and submit for grading before starting the next step. Only a portion of tests pass after each step but confirm progress. The main0 method in LabProgram java includes basic method calls. Add statements in main() as methods are completed to support development mode testing. Step 0. Declare private fields for number of customers served (int), total sales (double), and current amount due (double). Note the provided final variable for sales tax of 7%. Step 1 (1 pts). 1) Complete the constructor to initialize all private fields to zero. 2) Complete the accessor methods to return the number of customers served, total sales, and current amount due. Submit for grading to confirm 1 test passes: Step 2 ( 2 pt). Complete the scanitem0 method. Increase the amount due by parameter price. Do not update amount due if parameter price is negative. Submit for grading to confirm 3 tests pass. Step 3 (1 pt). Complete the checkOut() method. Multiply amount due by SALES_TAX and add to amount due. Submit for grading to confirm 4 tests pass Step 4 (2 pts). Complete the makePayment0 method. If parameter payment is enough to pay the amount due, increase total sales by amount due, increment number of customers served, and reset amount due to zero in preparation for the next customer. However, if parameter payment is not enough, update total sales by payment and reduce amount due by payment. Do not make any changes if parameter payment is negative. Submit for grading to confirm 6 tests pass. Step 5 (1 pt). 1) Complete the resetkiosk 0 method to reset all private fields to zero. 2) Complete the cancelTransaction0 method to reset amount due to zero. Submit for grading to confirm 7 tests pass. Step 6 (2 pts). Complete the simulateSales 0 method to perform multiple transactions with increasing prices. Use a loop to simulate. parameter numSales transactions. Within the loop, call scanitem0 with parameter initialPrice Call checkOut() and makePayment() to make. a payment of $1 more than the amount due. Finally, increase the item price by parameter incrprice in preparation for the next transaction. Submit for grading to confirm B tests pass Step 7 (1 pt). Add a boolean private field to indicate if the customer has checked out and is ready to make a payment Only allow payment after customer has checked out The canceltransaction0 method should not reset amount due if the customer has checked out Update. the foliowing methods by inserting assignment statements and if atatements related to the boolean filed constructor, checkOut . makePayment0. and canceirransaction0. Ex. Set the boolean field to talse only after full payment has been made. Submit for grading to confirm all tests pass. Current file: LabProgram.java * public class LabProgram \{ public static void main(String args) \{ SelfPaykiosk kiosk = new SelfPaykiosk() II Test basic operations kiosk. scanItem(20.49); kiosk, check0ut(); kiosk. makePayment (25.20); System.out, println( Number of customers: " + kiosk.getNumCustomers()); System, out, printf("Amount due: %,2fn, kiosk, getAmountDue()); System,out,printf("Total Sales: \%.2fn", kiosk,getTotalSalesO); Il Add statements as methods are coapleted to support developwent mode testing Current file: SelfPayKiosk.java - Current file: SelfPayKiosk.java * \} // Return number of customers served public int getNumCustomers() \{ / Update the return statment */ return 1; \} I/ scan one item public void scanItem(double price) \{ / " Complete the method */ 3) // Apply sales tax to current purchases public void checkout() \{ /* Complete the method */ \} 43444546 public void simulateSales(int numSales, double initialPrice, double incrPrice) \{

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

Data Management Databases And Organizations

Authors: Watson Watson

5th Edition

0471715360, 978-0471715368

More Books

Students also viewed these Databases questions

Question

Explain the concept of equal employment opportunity.

Answered: 1 week ago

Question

Explain the various job analysis methods.

Answered: 1 week ago

Question

Describe the components of a job description.

Answered: 1 week ago