Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main (String[] args) {
- Scanner scnr = new Scanner(System.in);
- int[] colors = new int[3];
- System.out.println("RED");
- colors[0] = scnr.nextInt();
- System.out.println("BLUE");
- colors[1] = scnr.nextInt();
- System.out.println("YELLOW");
- colors[2] = scnr.nextInt();
- System.out.println("WHITE");
- int white = scnr.nextInt();
- System.out.println("BLACK");
- int black = scnr.nextInt();
- int colorsum = 0;
- for(int i =0;i<colors.length;i++)
- {
- colorsum = colorsum+colors[i];
- }
- double[] rgbVal = {0,0,0};
- for(int j=0;j<colors.length;j++)
- {
- if(j==0)//red to red
- {
- }
- else if(j==1)//blue to blue
- {
- }
- else //yellow to red and green
- {
- }
- }
- Boolean boolWhite = true;
- int whiBlk = 0;
- if(white>black)
- {
- whiBlk = white-black;
- boolWhite=true;
- System.out.println(boolWhite + " " + whiBlk);
- }
- else if(black>white)
- {
- whiBlk=black-white;
- boolWhite=false;
- }
- else
- {
- whiBlk = 0;
- boolWhite=true;
- }
- for(int k=0;k<rgbVal.length;k++)
- {
- if(boolWhite)
- {
- rgbVal[k] = rgbVal[k] + (whiBlk*10);
- if(rgbVal[k]>=255)
- {
- rgbVal[k] = 255;
- }
- }
- else
- {
- rgbVal[k] = rgbVal[k] - (whiBlk*10);
- if(rgbVal[k]<=0)
- {
- rgbVal[k] = 0;
- }
- }
- }
- System.out.println("RGB values:" + (int)rgbVal[0] + "," + (int)rgbVal[1] + "," + (int)rgbVal[2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement