fork download
  1. import java.util.Scanner;
  2. class Main{
  3. static Scanner reader = new Scanner(System.in);
  4.  
  5. public static void main(String[] args){
  6. double= 3.5748;
  7. System.out.println("Enter the price");
  8. double price = reader.nextInt();
  9. //
  10. System.out.println("Enter the discount");
  11. double dis = reader.nextInt();
  12. //
  13. int num = 0;
  14. if(dis > 99){
  15. System.out.println("error");
  16. }else{
  17. double priceafter = price-dis*(price/100);
  18. System.out.println("the price is" + " " + priceafter);
  19. System.out.println("Would you like to exchange the discounted price from $ to ₪? (1=yes/2=no)");
  20. num = reader.nextInt();
  21. }
  22.  
  23. if(num == 1){
  24. System.out.println("The price is " + ((price-dis*(price/100))*) + "₪");
  25. }else if(num == 2) {
  26. System.out.println("The price is " + (price-dis*(price/100)) + "$");
  27. }else{
  28. System.out.println("error");
  29. }
  30. }
  31. }
Success #stdin #stdout 0.14s 2184192KB
stdin
10
5
1
stdout
Enter the price
Enter the discount
the price is 9.5
Would you like to exchange the discounted price from $ to ₪? (1=yes/2=no)
The price is 33.9606₪