Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Copy your program you wrote for Assignment 7 and rename the file Assign8.java an

ID: 3566181 • Letter: C

Question

Copy your program you wrote for Assignment 7 and rename the file Assign8.java and the class Assign8.
  
After displaying the same welcome message (greeting) as before, start a do while loop that will process and display everything that your Assignment 7 program does but, after displaying a single price with its calculated sales tax and total, prompt the user asking if he or she would like to do another. If so, have them enter a number 1. Any other number will stop the loop.
  
After the loop ends, display the same trailer (good-bye) message.
  
Please see the attached .txt document for sample output.

import java.util.Scanner;

import java.text.DecimalFormat;

public class Assign7
{
    public static void main(String[] args)
    {
    
      final double sales_tax_rate= 0.01;
    
      final double second_tax_rate= 0.0275;
    
      final double third_tax_rate= 0.035;
    
      final double fourth_tax_rate= 0.0475;
      
      double price,
      
             salesTax = 0,
      
             total;
    
      DecimalFormat currency = new DecimalFormat("$#,###,##0.00");
    
      Scanner keyScan = new Scanner(System.in);
    
      System.out.print("Welcome to the NIU Pricing Ststem");
      
      System.out.print(" Please enter the item's price: ");
    
      price = keyScan.nextDouble();
    
      System.out.printf(" Price: %13s " , currency.format(price));
          
      if(price>0&&price<75)
        {
         salesTax = price*fourth_tax_rate;
         }
       else if(75<= price && price <125)
         {
         salesTax = (price*second_tax_rate);
         }
       else if(125 <= price && price <225)
         {
       salesTax = (price*third_tax_rate);
         }
       else if(price>=225)
         {
       salesTax = (price*sales_tax_rate);
         }
    
      System.out.printf(" Sales Tax: %13s " , currency.format(salesTax));
    
      for(int i=0;i<13;i++)
      {
      System.out.print("-");
      }
      total = price + salesTax;
    
      System.out.printf(" Total: %13s ", currency.format(total));
    
      System.out.print(" Thank you for using the NIU Pricing System!");
    

    }
}

Assign 8 Output

Explanation / Answer

import java.util.Scanner;

import java.text.DecimalFormat;

public class Assign8{
   public static void main(String[] args) {

       final double sales_tax_rate = 0.01;

       final double second_tax_rate = 0.0275;

       final double third_tax_rate = 0.035;

       final double fourth_tax_rate = 0.0475;

       int value;

       double price,

       salesTax = 0,

       total;

       DecimalFormat currency = new DecimalFormat("$#,###,##0.00");

       Scanner keyScan = new Scanner(System.in);

       System.out.print("Welcome to the NIU Pricing Ststem");
       do {

           System.out.print(" Please enter the item's price: ");

           price = keyScan.nextDouble();

           System.out.printf(" Price: %13s ", currency.format(price));

           if (price > 0 && price < 75) {
               salesTax = price * fourth_tax_rate;
           } else if (75 <= price && price < 125) {
               salesTax = (price * second_tax_rate);
           } else if (125 <= price && price < 225) {
               salesTax = (price * third_tax_rate);
           } else if (price >= 225) {
               salesTax = (price * sales_tax_rate);
           }

           System.out
                   .printf(" Sales Tax: %13s ", currency.format(salesTax));

           for (int i = 0; i < 13; i++) {
               System.out.print("-");
           }
           total = price + salesTax;

           System.out.printf(" Total: %13s ", currency.format(total));
           System.out.println("Please enter '1' if you want to do another:");
           value = keyScan.nextInt();
       } while (value == 1);

       System.out.print(" Thank you for using the NIU Pricing System!");

   }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote