Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class GameCenter{
  3.  
  4. public static void main(String []args){
  5. Scanner input =new Scanner(System.in);
  6. //varables
  7.  
  8. double totalPrice=0;
  9. double priceAfterDiscount=0;
  10.  
  11.  
  12. System.out.println("Welcome to Gaming Center");
  13. System.out.println("please enter game Id");
  14. int id=input.nextInt();
  15. System.out.println("please enter the price of games");
  16. double price=input.nextDouble();
  17. System.out.println("please enter number of games");
  18. int num=input.nextInt();
  19. if(num<1)
  20. System.out.println("error");
  21. else{
  22. double Discount=20.0/100.0;
  23. totalPrice=price*num;
  24. if (num>2){
  25. priceAfterDiscount=totalPrice*(1-Discount);
  26. System.out.print("Total price for game "+id+" is:"+priceAfterDiscount+"SR");
  27. }
  28. else
  29. System.out.print("Total price for game "+id+" is:"+totalPrice+"SR");
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement