Results 1 to 5 of 5
  1. #1
    If ℜul℮s doηt b℮ηd, th℮y ฿r℮αk.
    Donator
    DarkByte7's Avatar
    Join Date
    Oct 2011
    Gender
    male
    Location
    n/a
    Posts
    368
    Reputation
    24
    Thanks
    368
    My Mood
    Cynical

    ANYONE HELP ME GOT A JAVA COMPILE ERROR!

    Im getting an error during compile time, and I am not very good with Java could anyone please help me with it?
    Code:
    import javax.swing.*;
    import java.util.*;
    
    public class Problem
    {
    public static void main(String [] args)
    {
    Scanner keyboard = new Scanner(System.in);
    int number1;
    int number2;
    int number3;
    
    
    
    System.out.println("Enter 3 numbers");
    number1 = keyboard.nextInt();
    number2 = keyboard.nextInt();
    number3 = keyboard.nextInt();
    
    If ((number1 > number2) && (number1 > number3));
    {
    System.out.println(number1);
    
    If (number2 > number3);
    {
    System.out.println(number2);
    System.out.println(number3);
    }
    
    else
    {
    System.out.println(number3);
    System.out.println(number2);
    }
    }
    
    else if ((number2 > number1) && (number2 > number3));
    {
    System.out.println(number2);
    
    If (number1 > number3);
    {
    System.out.println(number1);
    System.out.println(number3);
    
    }
    else
    {
    System.out.println(number3);
    System.out.println(number1);
    }
    }
    
    else
    {
    System.out.println(number3);
    
    If (number2 > number1);
    {
    System.out.println(number1);
    System.out.println(number2);
    }
    else
    {
    System.out.println(number2);
    System.out.println(number1);
    }
    }
    
    } //close main
    }


     


  2. #2
    Saltine's Avatar
    Join Date
    Jun 2011
    Gender
    male
    Posts
    493
    Reputation
    104
    Thanks
    629
    Everywhere you used the "if" keyword, you capitalized it. In java, everything is case sensitive, so you must change all of the "If"'s to "if"s.

  3. The Following User Says Thank You to Saltine For This Useful Post:

    DarkByte7 (11-23-2011)

  4. #3
    Threadstarter
    If ℜul℮s doηt b℮ηd, th℮y ฿r℮αk.
    Donator
    DarkByte7's Avatar
    Join Date
    Oct 2011
    Gender
    male
    Location
    n/a
    Posts
    368
    Reputation
    24
    Thanks
    368
    My Mood
    Cynical
    Quote Originally Posted by Saltine View Post
    Everywhere you used the "if" keyword, you capitalized it. In java, everything is case sensitive, so you must change all of the "If"'s to "if"s.
    OK I changed it just like you said, but I still get these errors.

    Code:
    test.java:30: error: 'else' without 'if'
    else
    ^
    test.java:37: error: 'else' without 'if'
    else if ((number2 > number1) && (number2 > number3));
    ^
    test.java:47: error: 'else' without 'if'
    else
    ^
    test.java:54: error: 'else' without 'if'
    else
    ^
    test.java:63: error: 'else' without 'if'
    else
    ^
    5 errors


     


  5. #4
    radnomguywfq3's Avatar
    Join Date
    Jan 2007
    Gender
    male
    Location
    J:\E\T\A\M\A\Y.exe
    Posts
    8,858
    Reputation
    381
    Thanks
    1,823
    My Mood
    Sad
    remove the semi-colons immediately following your condition in your ifs

    if(condition) statement\block;

    not if(condition); statement\block

    i.e change (and do this for all your other ifs...)
    Code:
    If (number2 > number3);
    			{
    				System.out.println(number2);
    				System.out.println(number3);
    			}
    			else
    			{
    				System.out.println(number3);
    				System.out.println(number2);
    			}
    to (notice lack of semi-colons following condition
    Code:
    If (number2 > number3)
    			{
    				System.out.println(number2);
    				System.out.println(number3);
    			}
    			else
    			{
    				System.out.println(number3);
    				System.out.println(number2);
    			}



    There are two types of tragedies in life. One is not getting what you want, the other is getting it.

    If you wake up at a different time in a different place, could you wake up as a different person?


  6. The Following User Says Thank You to radnomguywfq3 For This Useful Post:

    DarkByte7 (11-23-2011)

  7. #5
    Threadstarter
    If ℜul℮s doηt b℮ηd, th℮y ฿r℮αk.
    Donator
    DarkByte7's Avatar
    Join Date
    Oct 2011
    Gender
    male
    Location
    n/a
    Posts
    368
    Reputation
    24
    Thanks
    368
    My Mood
    Cynical
    Thank you the problem was solved.
    /request close


     


Similar Threads

  1. [Help] Does anyone know how to fix "Application load error 3:0000065432"?
    By Stevenom in forum Battlefield Bad Company 2 (BFBC2) Hacks
    Replies: 10
    Last Post: 07-18-2010, 10:51 PM
  2. Help I got This Error in The puB
    By ~Tabuzo013~ in forum CrossFire Help
    Replies: 0
    Last Post: 05-08-2010, 02:49 PM
  3. Help WarRock compile error
    By djxorwkd11 in forum C++/C Programming
    Replies: 2
    Last Post: 03-08-2010, 07:37 AM
  4. Errors in my D3D - Can anyone help?
    By inspired in forum C++/C Programming
    Replies: 5
    Last Post: 09-01-2008, 06:29 PM
  5. [HELP] making UCE compile error
    By herowarz in forum Suggestions, Requests & General Help
    Replies: 6
    Last Post: 02-03-2008, 12:35 AM