Question

In: Computer Science

Surfer Sam’s has a sale this Saturday, you need to reprogram the tills for the sale....

Surfer Sam’s has a sale this Saturday, you need to reprogram the tills for the sale. Write the Java code.

Ask for a product price. If the total price is less than or equal to $100, apply a discount of 3% to the total sale. If the price is more than $100 and less than or equal to 500, apply a discount of 5% to the total sale. If the price is higher than $500, apply a discount of 8% to the total sale. Add the GST and print out the: original price, the discount amount, GST and final price. The following is a sample, user input is shown in bold underline:

1st Sample Run:

Enter the price: 699.90

Description              Amount

Price                    699.90

% Discount                 8.00

Discount                  55.99

Summary                  643.91

GST                       32.20

Final Price              676.10

2nd Sample Run:

Enter the price: 29.95

Description              Amount

Price                     29.95

% Discount                 3.00

Discount                   0.90

Summary                   29.05

GST                        1.45

Final Price               30.50

Solve this problem using doubles.

please answer in java

Solutions

Expert Solution

CODE -

import java.util.Scanner;

public class sale

{

public static void main(String[] args) {

// Variable initialization double discount_per = 0, discount, totalPrice, gst, finalPrice;

Scanner keyboard = new Scanner(System.in);

// Take price as input from user

System.out.print("Enter the price: ");

double price = keyboard.nextDouble();

// Close the scanner

keyboard.close();

// Determine the discount percentage according to the price

if(price <= 100)

discount_per = 3;

else if (price <= 500)

discount_per = 5;

else if (price > 500)

discount_per = 8;

  

// Calculate the discount

discount = (discount_per * price) / 100;

// Calculate the price after discount

totalPrice = price - discount;

// Calculate the GST

gst = (5 * totalPrice) / 100;

// Calculate final price after including GST

finalPrice = totalPrice + gst;

// Displaying the details

System.out.printf("%-17s %s\n", "Description", "Amount");

System.out.printf("%-15s %8.2f\n", "Price", price);

System.out.printf("%-15s %8.2f\n", "/% Discount", discount_per);

System.out.printf("%-15s %8.2f\n", "Discount", discount);

System.out.printf("%-15s %8.2f\n", "Summary", totalPrice);

System.out.printf("%-15s %8.2f\n", "GST", gst);

System.out.printf("%-15s %8.2f\n", "Final Price", finalPrice);

}   

}

SCREENSHOTS -

CODE -

OUTPUT -

If you have any doubt regarding the solution, then do comment.

Do upvote.


Related Solutions

You plan to buy a house in July 2019. The sale price is $350,000. You need...
You plan to buy a house in July 2019. The sale price is $350,000. You need to pay 20% down payments and borrow additional 80% from Wells Fargo with a traditional 15-year, 3.6% fixed-rate mortgage loan. You are expected to pay an equal MONTHLY payment starting from August 2019 for a total of 15 years. (1) Calculate your expected monthly mortgage payment. (2) Develop the 2019~2034 amortization table for your mortgage loan. (1) When you prepare your 2019 tax filing,...
Iron Bridge offers the "Ten-Mile" rummage sale along route 322 to Runnymede on Saturday March 11th....
Iron Bridge offers the "Ten-Mile" rummage sale along route 322 to Runnymede on Saturday March 11th. Consumers who go to the sale will spend $60 each with 200 shoppers per mile in total over the length of the sale. They will incur an expense of $2 per mile one-way to travel to get yard goods. Shoppers are evenly distributed along the route and travel to the nearest booth. Vendors pay a $300 fee to participate in the sale and forego...
Case 2: Sam’s Paint and Drywall                                      
Case 2: Sam’s Paint and Drywall                                                                                    Sam's Paint and Drywall For the year ended December 31, 2019 (In thousands of dollars) Assets    Liabilities and Net Worth Cash              $12 Accounts Payable                     $15 Inventory 41 Notes Payable-Bank         4 Accounts Receivable 18 Other                                 20 Total Current Assets 71 Total Current Liabilities            39 Fixed Assets: Long Term Liabilities                41 Vehicles 10                                     Equipment 15               Building 22 Land 23 Total net worth (Owner’s Equity)           61 Total fixed assets 70 Total Fixed                                      ...
Sam’s Electronics Universe has discovered and investigated a kickback fraud perpetrated by its purchasing agent. The...
Sam’s Electronics Universe has discovered and investigated a kickback fraud perpetrated by its purchasing agent. The fraud lasted eight months and cost the company $2 million in excess inventory purchases. The perpetrator personally benefited by receiving kickbacks of $780,000. Your boss wants to seek restitution of what the company has lost, but is worried about the ramifications of a trial and its effect on your company’s image in the market. She is trying to decide if she should pursue remedies...
What evidence could you collect to confirm that the mutation identified in Sam’s DNA causes symptoms...
What evidence could you collect to confirm that the mutation identified in Sam’s DNA causes symptoms of RP?
QUESTION 11 You are at home in Royal Oak on a beautiful Saturday preparing for the...
QUESTION 11 You are at home in Royal Oak on a beautiful Saturday preparing for the arrival later that evening of some dinner guests when your doorbell rings. At the door is an enthusiastic young woman wearing a polo shirt with the words "Royal Oak Good Restaurant and Bar" embroidered on it. Handing you a business card with the ROGRB logo and the title "Vice President" on it, the woman explains that she works for the ROGRB and has a...
You and your roommates have decided to go to a fraternity party on Saturday night. You...
You and your roommates have decided to go to a fraternity party on Saturday night. You arrive at the fraternity house and see another classmate, Jenn, from your psychology class. You go over to say hello and see what she thought of the first exam, but Jenn seems to be acting very strangely. She starts describing fantastic colors made by the lights and how the dance floor is a beautiful sea of diamonds. You take a look around and realize...
The hostess at a busy restaurant has found that during a Saturday evening, the restaurant typically...
The hostess at a busy restaurant has found that during a Saturday evening, the restaurant typically has 14 diners entering every 18 minutes. What is the probability that exactly 13 people enter the restaurant during a random 18 minute period on a Saturday evening? What is the probability that exactly 10 people enter the restaurant during a random 9 minute window on a Saturday evening?
Determine whether Costco or Sam’s Club are the better company? Which company would you buy stock...
Determine whether Costco or Sam’s Club are the better company? Which company would you buy stock in and why?
Sam’s pasta is identical to the pasta made by dozens of other firms and there is...
Sam’s pasta is identical to the pasta made by dozens of other firms and there is free entry in the pasta. Buyers and sellers are well informed about prices.                      Points: 5                                                                                In what type of market does Sam’s operate? What determines the price of pasta? What determines Sam’s marginal revenue of pasta? If pasta sell for $5 a packet and Sam offers his pasta for sale at $5.50 a packet, how many packets does he sell? If pasta sell...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT