mcq-4,5,6 Java Dry-Run Programs Answers
mcq-4,5,6 Java Dry-Run Programs Answers
Q.4. An electronic shop has announced the following seasonal discounts on the purchase of laptops.[10]
Purchase Amount Discount
0-25000 0.0%
25001-50000 5.0%
50001-100000 7.5%
>100000 10.0%
Input the amount for 10 customers , calculate and print the discount for each and the total discount given for all the
customers .
import java.util.*;
class p
{public static void main()
{Scanner br=new Scanner(System.in);int I,p;
double d=0.0d,t=0.0d;
for(i=1;i<=10;i++)
{System.out.println(“enter purchase amount");
p=br.nextInt();
if(p>=0&&p<=25000)
d=0.0;
else if(p>25000 &&p<=50000)
d=0.05*p;
else if(p>50000&&p<=100000)
d=0.075*p;
else
d=0.10*p;
System.out.println(p+” “+d);
t=t+d;
}
System.out.println(t);}}