Advertisement
Mowmaster

tester color

Oct 13th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.02 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main (String[] args) {
  5.         Scanner scnr = new Scanner(System.in);
  6.  
  7.         int[] colors = new int[3];
  8.  
  9.         System.out.println("RED");
  10.         colors[0] = scnr.nextInt();
  11.         System.out.println("BLUE");
  12.         colors[1] = scnr.nextInt();
  13.         System.out.println("YELLOW");
  14.         colors[2] = scnr.nextInt();
  15.  
  16.         System.out.println("WHITE");
  17.         int white = scnr.nextInt();
  18.         System.out.println("BLACK");
  19.         int black = scnr.nextInt();
  20.  
  21.         int colorsum = 0;
  22.         for(int i =0;i<colors.length;i++)
  23.         {
  24.             colorsum = colorsum+colors[i];
  25.         }
  26.  
  27.         double[] rgbVal = {0,0,0};
  28.         for(int j=0;j<colors.length;j++)
  29.         {
  30.             if(j==0)//red to red
  31.             {
  32.  
  33.             }
  34.             else if(j==1)//blue to blue
  35.             {
  36.  
  37.             }
  38.             else //yellow to red and green
  39.             {
  40.  
  41.             }
  42.         }
  43.  
  44.         Boolean boolWhite = true;
  45.         int whiBlk = 0;
  46.         if(white>black)
  47.         {
  48.             whiBlk = white-black;
  49.             boolWhite=true;
  50.             System.out.println(boolWhite + " " + whiBlk);
  51.         }
  52.         else if(black>white)
  53.         {
  54.             whiBlk=black-white;
  55.             boolWhite=false;
  56.  
  57.         }
  58.         else
  59.         {
  60.             whiBlk = 0;
  61.             boolWhite=true;
  62.         }
  63.  
  64.         for(int k=0;k<rgbVal.length;k++)
  65.         {
  66.             if(boolWhite)
  67.             {
  68.                 rgbVal[k] = rgbVal[k] + (whiBlk*10);
  69.                 if(rgbVal[k]>=255)
  70.                 {
  71.                     rgbVal[k] = 255;
  72.                 }
  73.             }
  74.             else
  75.             {
  76.                 rgbVal[k] = rgbVal[k] - (whiBlk*10);
  77.                 if(rgbVal[k]<=0)
  78.                 {
  79.                     rgbVal[k] = 0;
  80.                 }
  81.             }
  82.         }
  83.  
  84.  
  85.         System.out.println("RGB values:" + (int)rgbVal[0] + "," + (int)rgbVal[1] + "," + (int)rgbVal[2]);
  86.  
  87.     }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement