[Solved] Exercises Chapter 6 Created Class Named Purchase Purchase Contains Invoice Number Amount S Q37204020
In the exercises in Chapter 6, you created a class namedPurchase. Each Purchase contains an invoice number, amount of sale,amount of sales tax, and several methods.
Now, write a program that declares an array of five Purchaseobjects and prompt a user for their values. As each Purchase objectis created, continuously prompt until the user enters an invoicenumber between 1000 and 8000inclusive and anon-negative sale amount. Prompt the user for values for eachobject and then display all the values.
Purchase.java
public class Purchase
{
private int invoiceNumber;
private double saleAmount;
private double tax;
private static final double RATE = 0.05;
public void setInvoiceNumber(int num)
{
invoiceNumber = num;
}
public void setSaleAmount(double amt)
{
saleAmount = amt;
tax = saleAmount * RATE;
}
public double getSaleAmount()
{
return saleAmount;
}
public int getInvoiceNumber()
{
return invoiceNumber;
}
public void display()
{
System.out.println(“Invoice #” + invoiceNumber +
” Amount of sale: $” + saleAmount + ” Tax: $” + tax);
}
}
PurchaseArray.java
import java.util.*;
public class PurchaseArray {
public static void main(String[] args) {
// Write your code here
}
}
Expert Answer
Answer to In the exercises in Chapter 6, you created a class named Purchase. Each Purchase contains an invoice number, amount of s… . . .
OR

