Question

Create a class named Purchase.
Each Purchase contains an invoice number, amount of sale, and amount of sales tax.
Include set methods for the invoice number and sale amount.
Within the set () method for the sale amount, calculate the sales tax as 5% of the sale amount.
Also include a display method that displays a purchase.
Save the file as Purchase.java
Create an application 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 has been entered.
When you prompt for a sale amount, do not proceed until the user has entered a non-negative value.
After a valid Purchase object has been created, display the object’s invoice number, sale amount, and sales tax.
Save the file as CreatePurchase.java

Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Purchase {

private int invoiceNumber; //Local variables for object to store data
private double amountSale, amountSalesTax, total;

public void setAmountSale(double sale) //public mutator for amountSale
{
amountSale = sale; //Set sale amount
amountSalesTax = 0.05 * amountSale; //Calculate tax amount
total = amountSale + amountSalesTax; //Calculate total...

This is only a preview of the solution. Please use the purchase button to see the entire solution

Related Homework Solutions

Interactive Command-Line Game in Java
Homework Solution
$50.00
Java
Programming
Coding
Game Development
Computer Science
Zork
Colossal Cave Adventure
Command Line
Maps
2D Grid
Win
Lose
Classes
OOP
Methods
Fields
String Values
Integers
Statements
Roman Numerals in Java
Homework Solution
$35.00
Java
Programming
Codes
Algorithms
Computer Science
Statements
Variables
Loops
Roman Numerals
Integers
Messages
Input
Output
Arabic Format
Strings
Integers
Java Program: True/False Answers
Homework Solution
$30.00
Java
Programming
Computer Science
Lecturer
Weekly Texts
Students
True/False Answers
Scores
Tests
Questions
Validation
Variables
Loops
Conditions
Java Programming: Integer Problems
Homework Solution
$20.00
Programming
Java
Computer Science
Integers
Variables
Average Values
Even Numbers
Odd Numbers
Loops
Statements
Input
Output
File Management
Conditions
Error Messages
Exceptions
Hangman Game Using Arrays
Homework Solution
$33.00
Computer Science
Game Development
Arrays
Programming
Java
Words
Codes
Letters
Hangman
Characters
Guessing
Input
Output
Drawing
Java Programming Problem
Homework Solution
$28.00
Java
Programming
Codes
Algorithms
Computer Science
Classes
Variables
Statements
Source Files
Input
Output
Constructors
Strings
Integers
Error Handling
Get help from a qualified tutor
Live Chats