Mudreco

Colores Mudreco

May 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 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. package ejerciciocolores;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author Mudreco
  13. */
  14. public class EjercicioColores {
  15.  
  16. static Scanner sc = new Scanner(System.in);
  17.  
  18. public static String Combinar(String C1) {
  19. String C2, C3;
  20.  
  21. System.out.println("Ingrese un segundo color primario");
  22. C2 = sc.nextLine();
  23. if (C1.equals("Azul")) {
  24. if (C2.equals("Rojo")) {
  25. C3 = "Magenta";
  26. } else if (C2.equals("Verde")) {
  27. C3 = "Cian";
  28. } else {
  29. C3 = "nada";
  30. }
  31. } else if (C1.equals("Rojo")) {
  32. if (C2.equals("Azul")) {
  33. C3 = "Magenta";
  34. } else if (C2.equals("Verde")) {
  35. C3 = "Amarillo";
  36. } else {
  37. C3 = "nada";
  38. }
  39. } else if (C1.equals("Verde")) {
  40. if (C2.equals("Azul")) {
  41. C3 = "Cian";
  42. } else if (C2.equals("Rojo")) {
  43. C3 = "Amarillo";
  44. } else {
  45. C3 = "nada";
  46. }
  47. } else {
  48. C3 = "nada";
  49. }
  50. return C3;
  51. }
  52.  
  53. public static void main(String[] args) {
  54.  
  55. System.out.println("Ingrese un color primario (Rojo, Azul o Verde)");
  56. String C1 = sc.nextLine();
  57. String CR = Combinar(C1);
  58. if (CR.equals("nada")) {
  59. System.out.println("Usted no ingreso colores primarios, o no los escribió correctamente");
  60. } else {
  61. System.out.println("Sus colores combinados crean: " + CR);
  62. }
  63. }
  64.  
  65. }
Add Comment
Please, Sign In to add comment