Q7Java please A company applies a discount based on the pric

Q7-Java please

A company applies a discount based on the price of the order. If the order is over $50, the discount is 5%. If the order is over $100, the discount is 10%. Otherwise, there is no discount. Write a sequence of if statements to get the discounted price of the order.

Solution

//tested on eclipse

import java.util.Scanner;
public class HelloWorld{

public static void main(String []args){
Scanner sc=new Scanner(System.in);
int order; //order variable
double discount; //discount variable
System.out.println(\"Enter order\"); //asking the user to enter amount of order
order=sc.nextInt();
/*sequence of if statement for calculation of discount */   
   if(order>50 && order<=100){   
discount=0.05*order;} //discount=5 percent
else if(order > 100){
discount=0.1*order;} //discount =10 percent
else{
System.out.println(\"There is no discount\");} //no discount
}
}

//end of java code

*******OUTPUT*****
Enter order   
50
There is no discount
*******OUTPUT*****

Please let me know in case of any doubt,Thanks.

Q7-Java please A company applies a discount based on the price of the order. If the order is over $50, the discount is 5%. If the order is over $100, the discou

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site