Advertisement
sternmcgee

Problem 13

Oct 25th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1.  
  2. /**
  3. * Prints the name of the color for the first letter of the color.
  4. *
  5. * @author Stern McGee
  6. * @version 10/25/14
  7. */
  8. import java.util.*;
  9. public class Problem13
  10. {
  11. public static void main(String[] args)
  12. {
  13. Scanner console=new Scanner(System.in);
  14. System.out.print("What color do you want? ");
  15. String color=console.next();
  16.  
  17. if(color=="B")
  18. {
  19. color="Blue";
  20. System.out.print("You have chosen "+color);
  21. }
  22. if(color=="G")
  23. {
  24. color="Green";
  25. System.out.print("You have chosen "+color);
  26. }
  27. if(color=="R")
  28. {
  29. color="Red";
  30. System.out.print("You have chosen "+color);
  31. }
  32.  
  33. if(color!="B"||color!="G"||color!="R")
  34. {
  35. System.out.print("Unknown color: "+color);
  36. }
  37. }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement