Question

In: Computer Science

My IDE : NETBEAN JAVA THANK YOU SO MUCH ( THE QUESTION IS ON SPECIFICATION) Sample...

My IDE : NETBEAN JAVA

THANK YOU SO MUCH ( THE QUESTION IS ON SPECIFICATION)

Sample Run

Department Store Sales Tax and Grand Total Application

Data Entries: Enter 0 to end your input
Cost of item: 35.99
Cost of item: 27.50
Cost of item: 19.59
Cost of item: 0
All items total: $83.08

Sales tax rate (%): 6
Promotion code: 123

Discount amount: $1.00
Subtotal: $82.08
Sales tax amount: $4.92
Grand total: $87.00

Continue? y/Y/n/N: y

Data Entries: Enter 0 to end your input
Cost of item: 10.99
Cost of item: 35.50
Cost of item: 11.52
Cost of item: 21.58
Cost of item: 0
All items total: $79.59

Sales tax rate (%): 12
Tax rate should be from 6 to 10
Sales tax rate (%): 9
Promotion code: 456

Discount amount: $2.00
Subtotal: $77.59
Sales tax amount: $6.98
Grand total: $84.57

Continue? y/Y/n/N: y

Data Entries: Enter 0 to end your input
Cost of item: 95.21
Cost of item: 0
All items total: $95.21

Sales tax rate (%): 10
Promotion code: 999
Invalid promotion code. Try again
Promotion code: 789

Discount amount: $3.00
Subtotal: $92.21
Sales tax amount: $9.22
Grand total: $101.43

Continue? y/Y/n/N: Y

Data Entries: Enter 0 to end your input
Cost of item: 152.50
Cost of item: 59.80
Cost of item: 0
All items total: $212.30

Sales tax rate (%): 8

Discount amount: $21.23
Subtotal: $191.07
Sales tax amount: $15.29
Grand total: $206.36

Continue? y/Y/n/N: N

Program is terminated

Specifications

  • The sales tax rate is from 6% to 10%.
  • The system accepts only the following promotion codes for a discount amount:
    • 123 ($1 discount)
    • 456 ($2 discount)
    • 789 ($3 discount)
    • 0 (no discount)
  • If the all items total is $100 or more, the discount amount is 10% of the total. No other discounts are applied.
  • The methods should round the results to a maximum of two decimal places. The subtotal, the sales tax amount, and the grand total are calculated as follows:
    • subtotal = all items total - discount amount
    • sales tax amount = subtotal * (sales tax rate / 100)
    • grand total = subtotal + sales tax amount
  • Store the code that gets user inputs and displays outputs in the main method.
  • Your project should contain one main class that defines the following static methods:
    • main()
    • getDiscount()
    • getItemsTotal()
    • getSalesTax()

Solutions

Expert Solution

/*
* Java program that prompts the user to enter the cost of items until
* user enters 0 to stop reading items. Then display the total items cost
* then prompt for sales tax in a range of 6 to 10. Then prompt for the promo code
* if the total amount is below 100 otherwise calculate a 10% discount on the total.
* Then calculate subtotal, sales tax, and grand total and display on java console.
* Continue the program until the user enters N or n to stop reading user input
* and terminate the program if the user enters n or N from the keyboard.
* */

//Store.java
import java.util.Scanner;
public class Store
{
   private static Scanner kboard=new Scanner(System.in);
   public static void main(String[] args)
   {
       System.out.println("Department Store Sales Tax and Grand Total Application");
       double total;
       String userchoice="y";
       do
       {
           //call method to read cost of items and get total cost of items
           total=getItemsTotal();
           System.out.printf("All items total: $%.2f\n",total);
           System.out.printf("Sales tax rate(%%): ");
           //read sales tax value
           double salestax=Double.parseDouble(kboard.nextLine());
           //validate the sales tax in between 6 and 10
           while(salestax<6 || salestax>10)
           {
               System.out.println("Tax rate should be from 6 to 10");
               System.out.printf("Sales tax rate(%%): ");
               salestax=Double.parseDouble(kboard.nextLine());
           }

           double discount;
           if(total<100)
           {
               System.out.printf("Promotion code: ");
               //Read promocode
               int promocode=Integer.parseInt(kboard.nextLine());
               while(!(promocode==123|| promocode==456|| promocode==789) )
               {
                   System.out.println("Invalid promotion code. Try again");
                   System.out.printf("Promotion code: ");
                   //Read promocode
                   promocode=Integer.parseInt(kboard.nextLine());
               }

               //calculate discount
               discount=getDiscount(promocode);
               System.out.printf("Discount amount: $%.2f\n",discount);  
           }
           else
           {
               discount=total*0.10;
           }
          
           //calculate subtotal
           double subtotal=total-discount;  
           System.out.printf("Subtotal: $%.2f\n",subtotal);
           //calcuate sales tax amount
           double salestaxamount=getSalesTax(subtotal, salestax);
           System.out.printf("Sales tax amount: $%.2f\n",salestaxamount);
           System.out.printf("Grand total: $%.2f\n",(subtotal+salestaxamount));
           //read userchoice
           System.out.print("Continue? y/Y/n/N: ");
           userchoice=kboard.nextLine();

       }while(!userchoice.equals("n") && !userchoice.equals("N"));
       System.out.println("Program is terminated");
   }//end of the method, main

   /*Method to find the sales tax amount*/
   public static double getSalesTax(double subtotal, double salestax)
   {
       double salestaxamount=subtotal * (salestax/ 100);
       return salestaxamount;
   }//end of the method, getSalesTax

   /*Method to find the discount amount on promocode*/
   public static double getDiscount(int promocode)
   {
       int discount=0;
       if(promocode==123)
           discount=1; //discount 1$
       else if(promocode==456)
           discount=2; //discount 2$
       else if(promocode==789)
           discount=3; //discount 3$
       else
           discount=0;
       return discount;
   }//end of the method, getDiscount

   /*Method to find the total cost of items*/
   public static double getItemsTotal()
   {
       double itemcost=0;
       double totalcost=0;
       System.out.println("Data Entries: Enter 0 to end your input");
       System.out.print("Cost of item: ");
       itemcost=Double.parseDouble(kboard.nextLine());
       while(itemcost!=0)
       {
           totalcost=totalcost+itemcost;
           System.out.print("Cost of item: ");
           itemcost=Double.parseDouble(kboard.nextLine());
       }
       return totalcost;
   }//end of the method, getItemsTotal
}

Sample output screenshot:


Related Solutions

HI please answer all parts of my question. Thank you so much! I will rate you!...
HI please answer all parts of my question. Thank you so much! I will rate you! Why do we call cardiac muscle to be a syncytium of many individual muscle cells? What is the name of membranes that connect longitudinally adjacent muscle cells? As you know the mechanism of organophosphates involves irreversible inhibitors of AChE. Organophosphates have been used in several murders (VX used to kill the half-brother of North Korean dictator Kim Jong Un; Sarin gas used to kill...
Thank you all. my other code is working fine. It was my IDE issue. This is...
Thank you all. my other code is working fine. It was my IDE issue. This is the new code i am writing for the below question. please help as you always do: a=int(input('Input a: ')); b=int(input('Input b: ')); c=int(input('Input c: ')); r=int(input('Input r: ')); s=int(input('Input s: ')); t=int(input('Input t: ')); x=2; min_rst = min(r,s,t); while(1): if((x-a)%r==0): if((x-b)%s==0): if((x-c)%t==0): break; x=x+1; print('The required number is: ',x); Questions: Write a Python program called crt.py that finds the value of x that satisfies...
So pretty much I need my code without the arrays, or lists. Please and thank you!...
So pretty much I need my code without the arrays, or lists. Please and thank you! Important: You may not use arrays, lists, or similar for your questions. This will be covered in the next module. The objective is to use conditionals in order to achieve the overall task. Checkpoint 3 is a continuation of the “Quiz” Programming Project. This module week, you will implement repetitive tasks in your program while using conditional and iteration statements in C#. Implement a...
Hey! I'm having trouble answering this for my assignment. Thank you so much in advance. 1)...
Hey! I'm having trouble answering this for my assignment. Thank you so much in advance. 1) Which type of vessels, arteries or veins, has more muscle fibers? What is the functional significance of this? 2a) In general, we have no conscious control over smooth muscle or cardiac muscle function, whereas we can consciously control to some extent all skeletal muscles. Can you consciously control your breathing? What does this tell you about the muscle type of the diaphragm? 2b) What...
Please answer each question and show calculation/ provide explanations. Thank you so much. Question 1 You...
Please answer each question and show calculation/ provide explanations. Thank you so much. Question 1 You have just been hired as the staff accountant for Maximum Corporation. However, the accounting manager is unclear about your ability to determine where certain increases and decreases should be placed. Indicate in the columns below by placing a check-mark (√        ) in the appropriate column identified. Office rent is increased.                                   Service Revenue is increased. Prepaid Expense is reduced. Cash is decreased. Plant and machinery...
Hi guys, ASAP please answer the question thank you so much!! A cyclist travelling at 8.0...
Hi guys, ASAP please answer the question thank you so much!! A cyclist travelling at 8.0 m/s is rounding a corner of radius 20 m on a flat road by leaning into the curve at an angle x with respect to the vertical. the coefficient of static friction between the tyres and the road is 0.80 and the rims and tyres are of negligible mass in comparison to the mass of the cycle and rider. 1. draw a diagram explicitly...
Answer Question: Thank you so much! Due 4/22/18 1. Who is/are the protoganist and antagonist in...
Answer Question: Thank you so much! Due 4/22/18 1. Who is/are the protoganist and antagonist in Westworld movie 1973? WHY?
FIND THE ANSWER WITH EXCEL PLEASE! THANK YOU SO MUCH! (2) The lifetime of a computer...
FIND THE ANSWER WITH EXCEL PLEASE! THANK YOU SO MUCH! (2) The lifetime of a computer circuit has an exponential distribution with mean of three years. Find the probability that a circuit lasts longer than 4 years.
PLEASE COMPUTE THE FOLLOWING IN EXCEL and show the excel sheet, Thank you so much! The...
PLEASE COMPUTE THE FOLLOWING IN EXCEL and show the excel sheet, Thank you so much! The following are the runs scored totals for 9 players for the 2016 New York Yankees: 56,43,63,68,58,80,71,32,19 (a) Find the mean and median (b) Find the standard deviation of this population (c) Considering this as a normal sample of American League players for the 2016 season, find a 99% Confidence Interval for the actual mean of Runs Scored for AL players, 2016 . (d) Considering...
Please Read This Article and answer the questions that follow: Thank You so much for taking...
Please Read This Article and answer the questions that follow: Thank You so much for taking the time to do this I will rate well!! In many cities, finding an available parking spot on the street seems about as likely as winning the lottery. But iflocal governments relied more on the price system, they might be able to achieve a more efficient allocation of this scarce resource. A Meter So Expensive, It Creates Parking Spots By Michael Cooper and Jo...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT