hi guys please help me.. please
please do this question by using scanner method in Java
Answers
Program:
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the cost : ");
int cost = sc.nextInt();
if( cost <= 2000 ){
System.out.println("The amount to be paid : "+(cost - (0.05 * cost))+" and gift is Calculator");
}else if(cost > 2000 && cost < 5000){
System.out.println("The amount to be paid : "+(cost - (0.1 * cost))+" and gift is School Bag");
}else if( cost > 5000 && cost < 10000){
System.out.println("The amount to be paid : "+(cost - (0.15 * cost))+" and gift is Wall Clock");
}else{
System.out.println("The amount to be paid : "+(cost - (0.2 * cost))+" and gift is Wrist watch");
}
}
}
Output:
Enter the cost :
2000
The amount to be paid : 1900.0 and gift is Calculator
Explanation:
- i took the cost into cost variable of type int
- and i check if it is upto 2000 or in between 2000 and 5000 or in between 5000 and 10000 or higher than 10000
- according to the if condition i wrote percentage code which will be deducted from the amount while it is printing
- and it will print the gift that the customer would get at the cost they mentioned
___hope my program will help you get what you wanted, if you liked my program mark brainliest, i would really help me :)