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...


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 thesales tax as 5% of the sale amount. Also include a display method that displays a purchase’s details.




import java.util.*;

public class CreatePurchase

{

   public static void main(String[] args)

   {

      Scanner input = new Scanner(System.in);

      Purchase purch = new Purchase();

      int num;

      double amount;

      String entry;

      final int LOW = 1000, HIGH = 8000;

      System.out.println("Enter invoice number");

      entry = input.next();

      num = Integer.parseInt(entry);

      while(num <= low || num >= HIGH)

      {

         System.out.println("Invoice number must be between " +

         LOW + " and " + HIGH + "\nEnter invoice number");

         entry = input.next();

         num = Integer.parseInt(entry);

      }


      System.out.println("Enter sale amount");

      entry = input.next();

      amount = Double.parseDouble(entry);

      while(amount <>

      {

         System.out.println("Enter sale amount");

         entry = input.next();

         amount = Double.parseDouble(entry);

      }

      purch.setInvoiceNumber(num);

      purch.setSaleAmount(amount);

      purch.display();

   }

}



Jun 08, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here