❓ Help JAVA Color Combination

Status
Not open for further replies.
Help naman po 'di ko sure kung tama yung code ko. Laging "Green" kasi yung results. 'di ko na kaya huhu help poo

import java.util.*;



public class Color_Selection {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int b = 1;
int y = 2;
int r = 3;

System.out.println("\n");
System.out.println("\tChoose your primary colors here ");
System.out.println(" 1 = blue\n 2 = yellow\n 3 = red\n ");
System.out.println("\n");

int colors;

System.out.println("\tEnter a Combination Color 1 : ");
colors= sc.nextInt();
System.out.println("\tEnter a Combination Color 2 : ");
colors= sc.nextInt();

System.out.println("\n");


if (1 != 2) {
System.out.println("\tThe result color is Green.");
}
else if (2 != 1) {
System.out.println("\tThe result color is Green.");
}
else if (2 != 3) {
System.out.println("\tThe result color is Orange.");
}
else if (3 != 2) {
System.out.println("\tThe result color is Orange.");
}
else if (3 != 1) {
System.out.println("\tThe result color is Violet.");
}
else if (1 != 3) {
System.out.println("\tThe result color is Violet.");
}

else {

System.out.println("\tWrong Color Combination. Try Again.");

}

System.out.println();

System.out.println("\tEnd of Program");

System.out.println("\n");

sc.close();

}
}

You do not have permission to view the full content of this post. Log in or register now.
 
Java:
import java.util.*;
public class Color_Selection {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("\n");
        System.out.println("\tChoose your primary colors here ");
        System.out.println(" 1 = blue\n 2 = yellow\n 3 = red\n ");
        System.out.println("\n");

        int color1,color2;

        System.out.println("\tEnter a Combination Color 1 : ");
        color1= sc.nextInt();
        System.out.println("\tEnter a Combination Color 2 : ");
        color2= sc.nextInt();

        System.out.println("\n");


        if ((color1 == 1 && color2 == 2) || (color1 == 2 && color2 == 1)) {
            System.out.println("\tThe result color is Green.");
        }
        else if ((color1 == 2 && color2 == 3) || (color1 == 3 && color2 == 2)) {
            System.out.println("\tThe result color is Orange.");
        }
        else if ((color1 == 1 && color2 == 3) || (color1 == 3 && color2 == 1)) {
            System.out.println("\tThe result color is Violet.");
        }

        else {

            System.out.println("\tWrong Color Combination. Try Again.");

        }

        System.out.println();

        System.out.println("\tEnd of Program");

        System.out.println("\n");

        sc.close();
    }
}
 
Java:
import java.util.*;
public class Color_Selection {
     public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        System.out.println("\n");
        System.out.println("\tChoose your primary colors here ");
        System.out.println(" 1 = blue\n 2 = yellow\n 3 = red\n ");
        System.out.println("\n");

        int color1,color2;

        System.out.println("\tEnter a Combination Color 1 : ");
        color1= sc.nextInt();
        System.out.println("\tEnter a Combination Color 2 : ");
        color2= sc.nextInt();

        System.out.println("\n");


        if ((color1 == 1 && color2 == 2) || (color1 == 2 && color2 == 1)) {
            System.out.println("\tThe result color is Green.");
        }
        else if ((color1 == 2 && color2 == 3) || (color1 == 3 && color2 == 2)) {
            System.out.println("\tThe result color is Orange.");
        }
        else if ((color1 == 1 && color2 == 3) || (color1 == 3 && color2 == 1)) {
            System.out.println("\tThe result color is Violet.");
        }

        else {

            System.out.println("\tWrong Color Combination. Try Again.");

        }

        System.out.println();

        System.out.println("\tEnd of Program");

        System.out.println("\n");

        sc.close();
    }
}
thank youu poo!
 
Status
Not open for further replies.

About this Thread

  • 2
    Replies
  • 442
    Views
  • 2
    Participants
Last reply from:
Hamburger24

Trending Topics

Online now

Members online
1,098
Guests online
6,315
Total visitors
7,413

Forum statistics

Threads
2,354,277
Posts
29,383,027
Members
1,079,397
Latest member
tobzlim3
Back
Top