Advertisement
Guest User

java

a guest
Mar 29th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.27 KB | None | 0 0
  1. package pct;
  2. import java.util.Scanner;
  3. public class Login {
  4. public static void main(String[] args) {
  5.     System.out.println("Enter your user name");
  6.     System.out.println("Avaliable users (tyler) (guest)");
  7.     Scanner input = new Scanner(System.in);
  8.     String username;
  9.     username=input.nextLine();
  10.     switch(username){
  11.        
  12.     case "tyler":System.out.println("Enter your password");
  13.     String tpass=input.nextLine();
  14.     if(tpass.equals("pass123")){
  15.        
  16.        
  17.         System.out.println("Welcome to the system");
  18.         System.out.println("enter 1 for cal");
  19.         int choice;
  20.         choice=input.nextInt();
  21.         switch(choice){
  22.        
  23.         case 1: int num1,num2,ans=0,howsolve;
  24.            
  25.            
  26.             System.out.println("Enter a number");
  27.                num1=input.nextInt();
  28.                System.out.println("Enter a second number");
  29.                num2=input.nextInt();
  30.                System.out.println("How do you want to solve");
  31.                System.out.println("1 for + 2 for - 3 for * 4 for /");
  32.                howsolve=input.nextInt();
  33.                switch(howsolve){
  34.                
  35.                case 1:ans=num1+num2;
  36.                break;
  37.                case 2:ans=num1-num2;
  38.                break;
  39.                case 3:ans=num1*num2;
  40.                break;
  41.                case 4:ans=num1/num2;
  42.                    break;
  43.              
  44.                
  45.                
  46.                }
  47.        
  48.         System.out.println("The answer is "+ans);
  49.        
  50.         }
  51.        
  52.        
  53.     }else{System.out.println("Wrong password restart!");}
  54.         break;
  55.     case "guest":System.out.println("Hello Guest");
  56.     System.out.println("Welcome to the system");
  57.     System.out.println("enter 1 for cal");
  58.     int choice;
  59.     choice=input.nextInt();
  60.     switch(choice){
  61.    
  62.     case 1: int num1,num2,ans=0,howsolve;
  63.        
  64.        
  65.         System.out.println("Enter a number");
  66.            num1=input.nextInt();
  67.            System.out.println("Enter a second number");
  68.            num2=input.nextInt();
  69.            System.out.println("How do you want to solve");
  70.            System.out.println("1 for + 2 for - 3 for * 4 for /");
  71.            howsolve=input.nextInt();
  72.            switch(howsolve){
  73.            
  74.            case 1:ans=num1+num2;
  75.            break;
  76.            case 2:ans=num1-num2;
  77.            break;
  78.            case 3:ans=num1*num2;
  79.            break;
  80.            case 4:ans=num1/num2;
  81.                break;
  82.          
  83.            
  84.            
  85.            }
  86.    
  87.            System.out.println("The answer is "+ans);
  88.    
  89.     }
  90.    
  91.    
  92.    
  93.    
  94.    
  95.    
  96.         break;
  97.    
  98.    
  99.    
  100.    
  101.     }
  102. }
  103.  
  104.  
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement