Advertisement
heysoul_sisypus

name input (string)

Feb 1st, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package yourmama;
  8. import java.util.*;
  9. /**
  10.  *
  11.  * @author Student
  12.  */
  13. public class Yourmama {
  14.  
  15.     /**
  16.      * @param args the command line arguments
  17.      */
  18.     public static void main(String[] args) {
  19.         Scanner scan =new Scanner (System.in);
  20.         System.out.print("Choose color - r/R y/Y b/B: ");
  21.         String c=scan.nextLine();
  22.         System.out.println(" ");
  23.         if(c.equals("R")|| c.equals("r"))
  24.         {System.out.println("Red");}
  25.         else if(c.equals("Y")|| c.equals("y"))
  26.         {System.out.println("Yellow");}
  27.         else if(c.equals("B")|| c.equals("b"))
  28.         {System.out.println("Blue");}
  29.         else
  30.         {System.out.println("Out of range");}
  31.        
  32.     }
  33. }
  34.  
  35. /*
  36.  *Input with .toUppercase shortcut
  37.  */
  38. package yourmama;
  39. import java.util.*;
  40. /**
  41.  *
  42.  * @author Student
  43.  */
  44. public class Yourmama {
  45.  
  46.     /**
  47.      * @param args the command line arguments
  48.      */
  49.     public static void main(String[] args) {
  50.         Scanner scan =new Scanner (System.in);
  51.         System.out.print("Choose color - r/R y/Y b/B: ");
  52.         String c=scan.nextLine();
  53.         c=c.toUpperCase();
  54.         System.out.println(" ");
  55.         if(c.equals("R"))
  56.         {System.out.println("Red");}
  57.         else if(c.equals("Y"))
  58.         {System.out.println("Yellow");}
  59.         else if(c.equals("B"))
  60.         {System.out.println("Blue");}
  61.         else
  62.         {System.out.println("Out of range");}
  63.        
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement