Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a class named Purchase. Each Purchase contains an invoice number ( invoiceNumber ) , amount of sale ( saleAmount ) , and amount of

Create a class named Purchase. Each Purchase contains an invoice number (invoiceNumber), amount of sale (saleAmount), and amount of sales tax (tax). Include set and get methods for the invoice number and sale amount. Within the set method for the sale amount, calculate the sales tax as 5 percent of the sale amount. Also include a display method that displays a purchase's details.
Next, create an application called CreatePurchase that declares a Purchase object and prompts the user for purchase details. When you prompt for an invoice number, do not let the user proceed until a number between 1,000 and 8,000 inclusive has been entered. When you prompt for a sale amount, do not proceed until the user has entered a nonnegative value. After a valid Purchase object has been created, display the object's invoice number, sale amount, and sales tax.
An example of the code is shown below:
Enter invoice number 2385
Enter sale amount 4081.28
Invoice #2385 Amount of sale: $4081.28 Tax: $204.06400000000002
image text in transcribed

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions