Advertisement
lineoff

TPrwaq

Jun 5th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MainClass {
  4.  
  5.     public static void main(String[] args) {
  6.         // TODO Auto-generated method stub
  7.        
  8.         Scanner mySc = new Scanner(System.in);
  9.         int id;
  10.         int nbGame;
  11.         double gPrice;
  12.         //double fPrice;
  13.        
  14.         System.out.println("Welcome to game center :).");
  15.         System.out.print("Please, Enter the game id:");
  16.         id = mySc.nextInt();
  17.        
  18.         System.out.print("Please, Enter the price of a game:");
  19.         gPrice = mySc.nextDouble();
  20.        
  21.         System.out.print("Please, Enter number of games:");
  22.         nbGame = mySc.nextInt();
  23.        
  24.         //System.out.println("");
  25.         System.out.println((nbGame == 0)?"Error" : (nbGame>2)?"Total price for game "+id+" is "+((double)nbGame*gPrice - (double)nbGame*gPrice*0.2)+" SR":"Total price for game "+id+" is "+((double)nbGame*gPrice) +" SR");
  26.        
  27.        
  28.        
  29.        
  30.         mySc.close();
  31.     }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement