Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package ejerciciocolores;
- import java.util.Scanner;
- /**
- *
- * @author Mudreco
- */
- public class EjercicioColores {
- static Scanner sc = new Scanner(System.in);
- public static String Combinar(String C1) {
- String C2, C3;
- System.out.println("Ingrese un segundo color primario");
- C2 = sc.nextLine();
- if (C1.equals("Azul")) {
- if (C2.equals("Rojo")) {
- C3 = "Magenta";
- } else if (C2.equals("Verde")) {
- C3 = "Cian";
- } else {
- C3 = "nada";
- }
- } else if (C1.equals("Rojo")) {
- if (C2.equals("Azul")) {
- C3 = "Magenta";
- } else if (C2.equals("Verde")) {
- C3 = "Amarillo";
- } else {
- C3 = "nada";
- }
- } else if (C1.equals("Verde")) {
- if (C2.equals("Azul")) {
- C3 = "Cian";
- } else if (C2.equals("Rojo")) {
- C3 = "Amarillo";
- } else {
- C3 = "nada";
- }
- } else {
- C3 = "nada";
- }
- return C3;
- }
- public static void main(String[] args) {
- System.out.println("Ingrese un color primario (Rojo, Azul o Verde)");
- String C1 = sc.nextLine();
- String CR = Combinar(C1);
- if (CR.equals("nada")) {
- System.out.println("Usted no ingreso colores primarios, o no los escribió correctamente");
- } else {
- System.out.println("Sus colores combinados crean: " + CR);
- }
- }
- }
Add Comment
Please, Sign In to add comment