Question

In: Computer Science

Use JAVAfor this program Program Description You work in a local gift shop that is currently...

Use JAVAfor this program

Program Description

You work in a local gift shop that is currently running a large sale. You have been asked to create a program to calculate the total of a user’s purchases and determine if they qualify for a discount. Use the following steps to create the program:

  1. Ask the user the price of the item they wish to purchase.
  2. Ask the user the quantity they wish to purchase.
  3. Ask the user to enter the name of the item they wish to purchase.
  4. Calculate the subtotal of the purchase. The subtotal of the purchase is calculated by the following equation:

Subtotal = Price * Quantity

  1. Calculate the discount amount using the equation and table below:

Subtotal

Discount

Under $25

5% discount

$25 but not more than $75.

10% discount

Over $75

15% discount

Discount Amount = Subtotal * (Discount/100)

  1. Calculate the discounted cost of the purchase. The discounted cost of the purchase is calculated by the following equation:

Discounted Cost = Subtotal - Discount Amount

  1. Create a String object in memory to hold the text: “Discount Calculation Utility”.
  2. Display the text at the top of the output (See Sample Input and Output)
  3. Display the item name, price, quantity, subtotal, discount, and total.
  4. Format the output of the program exactly as shown in the sample output (including indentation, spacing, and a number of decimal places).

Sample Input and Output (formatting, spacing, and indentation should be as shown below)

What is the price of the item you wish to purchase? 17.99
What is the quantity you wish to purchase? 3
What is the name of the item? T-Shirt

Discount Calculation Utility
Item Name:        T-Shirt
Price: $17.99
Quantity:             3
Subtotal: $53.97
Discount: $5.40
Discounted Cost: $48.57

Solutions

Expert Solution

All the explanation is in the comments of the code itself.

Code--

import java.util.*;
public class GiftShop
{
   public static void main(String[] args)
   {
       Scanner sc=new Scanner(System.in);
       double price,subtotal,discountAmt,discountedCost;
       int quantity,discount;
       String name;
       //ask the user the price of the item
       System.out.print("What is the price of the item you wish to purchase? ");
       price=sc.nextDouble();
       //ask the user for quantity
       System.out.print("What is the quantity you wish to purchase? ");
       quantity=sc.nextInt();
       sc.nextLine();
       //ask the user for item name
       System.out.print("What is the name of the item? ");
       name=sc.nextLine();
       //do the required calculation
       subtotal=price*quantity;
       //find the discount
       if(subtotal<(double)25)
       {
           discount=5;
       }
       else if(subtotal<(double)75)
       {
           discount=10;
       }
       else
       {
           discount=15;
       }
       discountAmt=subtotal*((double)discount/100);
       discountedCost=subtotal-discountAmt;
      
       //create a string object
       String str=new String("Discount Calculation Utility");
      
       //display the output
       System.out.println(str);
       System.out.println("Item Name:\t"+name);
       System.out.printf("Price: $%.2f\n",price);
       System.out.println("Quantity:\t"+quantity);
       System.out.printf("Subtotal: $%.2f\n",subtotal);
       System.out.printf("Discount: $%.2f\n",discountAmt);
       System.out.printf("Discounted Cost: $%.2f\n",discountedCost);
      
   }
}

Output Screenshot--

Note-

Please upvote if you like the effort.


Related Solutions

Prepare a basic S.W.O.T analysis for any local gift shop.
Prepare a basic S.W.O.T analysis for any local gift shop.
A local gift shop is trying to determine how many photos frames to order. The shop...
A local gift shop is trying to determine how many photos frames to order. The shop feels it will sell approximately 800 photos frames in the next year at a unit price of R18.00.The wholesale price that the store pays per photo frame is R12.00. The cost of carrying one photo frame is estimated at R1.60 per year, while ordering costs are estimated at 825.00 per batch ordered. REQUIRED (a) Explain the meaning of economic order quantity (EOQ) and reorder...
c++ program You are to use a Heap data structure for this assignment I currently work...
c++ program You are to use a Heap data structure for this assignment I currently work for an investment/insurance company and I’m looking for clients to call, ones with funds.  I need to have a schedule that shows the list of customers to call and the order to be called.  The list of customers names and phone numbers are in the file ‘NamesAndPhoneV2.txt’.  A second file contains a net worth value for each client.  The files are separated for security and protection reasons, but...
Problem Description A local veterinarian at The Pet Boutique has asked you to create a program...
Problem Description A local veterinarian at The Pet Boutique has asked you to create a program for her office to create invoices for her patient’s office visits. When a customer brings their pet to the boutique, the clerk gets the Customer’s name, address, phone number and email address, as well as the pets name, pet type, pet age, and pet weight. After the customer sees the Veterinarian, the clerk determines the charges for the services, and medications for the office...
Q1. Quickmeal Description of data Quickmeal is a local grocery shop that carries a limited variety...
Q1. Quickmeal Description of data Quickmeal is a local grocery shop that carries a limited variety of meat products, vegetable and fruits, dairy products, and beverages. The owner of Quickmeal, let’s call him John, wants to expand his business. John wants to understand the purchasing behaviour of his customers, so he can predict future demands. He recorded daily sales of products in June. The dataset is called “Quickmeal”, which is available in different formats. It shows the daily sales in...
Program Description A local company has requested a program to calculate the cost of different hot...
Program Description A local company has requested a program to calculate the cost of different hot tubs that it sells. Use the following instructions to code the program: File 1 - HotTubLastname.java Write a class that will hold fields for the following: The model of the hot tub The hot tub’s feature package (can be Basic or Premium) The hot tub’s length (in inches) The hot tub’s width (in inches) The hot tub’s depth (in inches) The class should also...
You are currently part of a university work experience program. Your job placement is at the...
You are currently part of a university work experience program. Your job placement is at the municipal transit centre. Your supervisor is responsible for the recording and distribution of monthly transit passes to authorized vendors throughout the city. The vendors pay €50 per bus pass and sell them for €55. Your job is to prepare a monthly reconciliation of the transit passes including the quantity sold, the number actually distributed, the unsold passes, and the cash proceeds. You are unable...
You plan to borrow ​$40,000 from the bank to pay for inventories for a gift shop...
You plan to borrow ​$40,000 from the bank to pay for inventories for a gift shop you have just opened. The bank offers to lend you the money at 14 percent annual interest for the 3 months the funds will be needed​ (assume a​360-day year). a.  Calculate the annualized rate of interest on the loan. b.  In​ addition, the bank requires you to maintain a 15 percent compensating balance in the bank. Because you are just opening your​ business, you...
You plan to borrow ​$10,000 from the bank to pay for inventories for a gift shop...
You plan to borrow ​$10,000 from the bank to pay for inventories for a gift shop you have just opened. The bank offers to lend you the money at 8 percent annual interest for the 3 months the funds will be needed​ (assume a​ 360-day year). a.  Calculate the annualized rate of interest on the loan. b.  In​ addition, the bank requires you to maintain a 14 percent compensating balance in the bank. Because you are just opening your​ business,...
You plan to borrow ​$50000 from the bank to pay for inventories for a gift shop...
You plan to borrow ​$50000 from the bank to pay for inventories for a gift shop you have just opened. The bank offers to lend you the money at 9 percent annual interest for the 3 months the funds will be needed​ (assume a​ 360-day year). a.  Calculate the annualized rate of interest on the loan. b.  In​ addition, the bank requires you to maintain a 20 percent compensating balance in the bank. Because you are just opening your​ business,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT