In: Computer Science
Create an application that allows the user to enter the total for an order and the name of the customer. If the order is less than 500 dollars, the customer gets no discount. If the order is greater than or equal to 500 and less than 1000 dollars, the customer gets a 5 percent discount. If the order is greater than or equal to 1000 dollars, the customer gets a 10 percent discount. The application should display the name of the customer and the discounted total.
I am using to create solution for your problem. I hope it will help
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
System.out.print("Please enter your name : ");
String name = s.nextLine();
System.out.println("Enter your order total int dollars : ");
double total = s.nextDouble();
double discount = 0;//initial value
if(total<500)
discount = 0;
else if(total<1000)//there is no need to check value with 500 as if total must not be less than 500 as if condition above is not true
discount = 5;
else //there is no need to check value now as else if condition above is not true
discount = 10;
System.out.println("Hello " + name + " your discounted price is " + (total - total*discount/100));
}
}
So, I hope I am able to solve your problem, If yes then do give it a thumbs up.It really helps :)