I need this to be in Java Code that runs as a program, I already have the flowch
ID: 3688658 • Letter: I
Question
I need this to be in Java Code that runs as a program, I already have the flowchart completed: Secondhand Shop is having a seven-day sale during which the price of any unsold item drops 10 percent each day.For example,an item that costs $10.00 on the first day costs 10 percent less,or $9.00, on the second day.On the third day,the same item is 10 percent less than $9.00,or $8.10.Design an application that allows a user to input a price until an appropriate sentinel value is entered.Output is the price of each item on each day,one through seven.
Explanation / Answer
import java.text.DecimalFormat;
import java.util.Scanner;
public class HelloWorld {
Scanner scanner = new Scanner(System.in);
public void run() {
System.out.println("Type a price");
double price = scanner.nextDouble();
for (int day = 1; day <= 7; day++) {
System.out.println("Day " + day + ": " + new DecimalFormat("$0.00").format(price));
price = price - (price * .10);
}
}
public static void main(String[] args) {
new HelloWorld().run();
}
}
sample output
Type a price
10
Day 1: $10.00
Day 2: $9.00
Day 3: $8.10
Day 4: $7.29
Day 5: $6.56
Day 6: $5.90
Day 7: $5.31
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.