Results 1 to 4 of 4
  1. #1
    Chinese is offline Member
    Join Date
    Dec 2015
    Posts
    5
    Rep Power
    0

    Default Guys I need help with my program

    It keeps on giving me errors :(
    Java Code:
    import java.util.Scanner;
    public class BMIProgram
    {
      public static void main(String[]args)
      {
        
        String GREEN, BLUE, RED, CYAN, MAGENTA, FIRSTCLR, SCNDCLR, YELLOW;
        Scanner inputDevice= new Scanner(System.in);
        System.out.println("\nCOLOR MIXER \n");
         
        System.out.print("INPUT FIRST COLOR     :");
         FIRSTCLR=inputDevice.nextLine();
        
        System.out.print("INPUT SECOND COLOR   :"); 
        SCNDCLR=inputDevice.nextLine();
        if(FIRSTCLR==GREEN && SCNDCLR==BLUE || FIRSTCLR==BLUE && SCNDCLR==GREEN)
     
        {
            System.out.print(" THE COLOR RESULT WOULD BE : CYAN");
        }
        else if(FIRSTCLR==BLUE && SCNDCLR==RED || FIRSTCLR==RED && SCNDCLR==BLUE)
        {
            System.out.print(" THE COLOR RESULT WOULD BE : MAGENTA");
        }
          else if(FIRSTCLR==GREEN && SCNDCLR==RED || FIRSTCLR==RED && SCNDCLR==GREEN)
        {
            System.out.print(" THE COLOR RESULT WOULD BE : YELLOW");
        }
         else
         {
           System.out.println("COLOR NOT MIXABLE THROUGH THIS PROGRAM");
         }
        System.out.println("\n<<END OF PROGRAM>>");
      }
    }
    ERRORS:
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 16]
    Error: The local variable GREEN may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 16]
    Error: The local variable BLUE may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 16]
    Error: The local variable BLUE may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 16]
    Error: The local variable GREEN may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 21]
    Error: The local variable BLUE may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 21]
    Error: The local variable RED may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 21]
    Error: The local variable RED may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 21]
    Error: The local variable BLUE may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 25]
    Error: The local variable GREEN may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 25]
    Error: The local variable RED may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 25]
    Error: The local variable RED may not have been initialized
    File: C:\Users\x451\Downloads\Desktop\BMIProgram.java [line: 25]
    Error: The local variable GREEN may not have been initialized

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Guys I need help with my program

    Have a look at the first error: what is the value of variable GREEN supposed to be? Nowhere in your code you're initializing it ...

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  3. #3
    Chinese is offline Member
    Join Date
    Dec 2015
    Posts
    5
    Rep Power
    0

    Default Re: Guys I need help with my program

    How could I initialize it? :))

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,423
    Blog Entries
    7
    Rep Power
    27

    Default Re: Guys I need help with my program

    Quote Originally Posted by Chinese View Post
    How could I initialize it? :))
    Give it a value, e.g. like so:
    Java Code:
    String GREEN= "blue";
    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. Hey Guys!
    By 6footGeek in forum Introductions
    Replies: 1
    Last Post: 01-26-2014, 04:04 PM
  2. Hey guys!
    By Rewl in forum Introductions
    Replies: 0
    Last Post: 01-06-2011, 02:33 AM
  3. Hi guys,
    By pereira.lawrence.java in forum Introductions
    Replies: 0
    Last Post: 03-17-2009, 03:55 AM
  4. Hello Guys!
    By jeraldjamescapao in forum Advanced Java
    Replies: 1
    Last Post: 11-22-2008, 07:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •