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

In java write code for: Fireworks Stand Checkout Scenario Your algorithm will ke

ID: 3921353 • Letter: I

Question

In java write code for:

Fireworks Stand Checkout

Scenario

Your algorithm will keep track of a customers’ purchases at the local fireworks stand. Customers will not know exactly how many items they will purchase, so using a For loop on this is not allowed. Let’s keep the rules simple.

1. Accept the dollar value of each item purchased from the user until the user is finished.

2. When purchases are complete, enter a sentinel value of -1 (indicating that the user has finished).

3. If the item purchased is $50.00 or more, give your customer a 10% discount on the item purchased.

4.Display all of the purchases to the customer with the original price and the discount price.

Explanation / Answer

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;

/**
*
* @author deepanshugupta
*/
public class Purchase {
private double originalPrice,discountedPrice;
  
public Purchase(double original,double discount)
{
originalPrice = original;
discountedPrice = discount;
}
  
public double getOriginalPrice()
{
return originalPrice;
}
  
public double getDiscountedPrice()
{
return discountedPrice;
}
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package chegg;

import java.util.ArrayList;
import java.util.Scanner;

public class TestFireWorks {

  
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
ArrayList<Purchase> purchases = new ArrayList<Purchase>();
  
double price = 0;
  
while(true)
{
System.out.println("Enter value of item purchased or press -1 if finished : ");
price = input.nextDouble();
  
if(price==-1)
break;
else
{
if(price>=50)
purchases.add(new Purchase(price,price*0.90));
else
purchases.add(new Purchase(price,price));
}
}
  
if(purchases.size()>0)
{
System.out.println("Below are list of purchases : ");
int i=1;

for(Purchase p : purchases)
{
System.out.println("Purchase " + i + " : Original = " + p.getOriginalPrice() + " ,Discounted = "+p.getDiscountedPrice());
}
}
}
  
}

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