import java.util.Scanner;
public class LoopPatterns {

    /**
     * @param args
     */
    public static void main(String[] args) {
    public static double Largest {  
                Scanner s = new Scanner(System.in);
                int num, largest = 0;

                for ( int i = 1; i <= 10 ;i ++) {
                 System.out.print("Enter a number : ");
                 num = s.nextInt();
                 if ( num > largest)
                      largest = num;
                }
                System.out.println("Largest Number : " + largest);



    public static double First {

            String name1, name2, name3 ;
            boolean b, b1;
            int i, i1, i2,i3;
            Scanner keyboard = new Scanner(System.in);

            System.out.print("Enter first string: ");
            name1 = scan.nextLine();

            System.out.print("Enter second string: ");
            name2 = scan.nextLine();

            System.out.print("Enter third string: ");
            name3 = scan.nextLine();

            b = name1.equals(name2);
             // Check if identical ignoring case

    b1 = name1.equalsIgnoreCase(name2);

        i = name1.compareTo(name2);

    if (i < 0)
        {
            i1 = name1.compareToIgnoreCase(name3);

             if (i1 < 0)
                {
        System.out.println(name1);
        if (i1 > 0)
            {
            System.out.println(name3);
            i2 = name2.compareToIgnoreCase(name3);
                if (i2<0)
                {
                    System.out.println(name2);
                    System.out.println(name3);
                }
                if (i2>0)
                {
                    System.out.println(name3);
                    System.out.println(name2);
                }
                }
                }
    }
    else if (i > 0)
        {

            i1 = name2.compareToIgnoreCase(name3);

             if (i1 < 0)
                {
        System.out.println(name2);
        if (i1 > 0)
            {
            i2 = name1.compareToIgnoreCase(name3);
                if (i2<0)
                {
                    System.out.println(name1);
                    System.out.println(name3);
                }
                if (i2>0)
                {
                    System.out.println(name3);
                    System.out.println(name1);
                }
                }
                }
    }

                }
    }
    }

}

this is my code for calculating the largest number from a set of numbers and returing a string in reverse order what are my errors ?

what are my errors ?

Please post the full text of any error messages so we can see them.
Or if there are no error messages, please explain your problem.

The formatting for the posted code is very bad. Each nested pair of {}s should be indented 3-4 spaces so you can easily see the logic. There should not be a column of }s one under the other.

The ending "}" should be vertically in line beneath the line with the pairing "{"

For example:

  for(int i=0;i<A.length;i++){
    int c = 1;      // start with one

    for(int j=i+1;j<A.length;j++) {
      if (A[i]==A[j]) {
        c=c+1;
        System.out.println("c="+c +" A[i]="+A[i] + ", i=" + i + ", j="+j);
        if (c>(A.length/2)){
           return A[i];
        }
      }
    } //  end for(j)
  }  // end for(i)

Edited 4 Years Ago by NormR1

import java.util.Scanner;

public class LoopPatterns {

    /**
     * @param args
     */
    public static void main(String[] args) {
        public static double Largest () {   
            Scanner s = new Scanner(System.in);
            int num, largest = 0;

            for ( int i = 1; i <= 10 ;i ++) {
                System.out.print("Enter a number : ");
                num = s.nextInt();
                if ( num > largest)
                    largest = num;
            }
            System.out.println("Largest Number : " + largest);



            public static double First (String name1, name2, name3 ;
                boolean b, b1;
                int i, i1, i2,i3;) {


                Scanner keyboard = new Scanner(System.in);

                System.out.print("Enter first string: ");
                name1 = keyboard.nextLine();

                System.out.print("Enter second string: ");
                name2 = keyboard.nextLine();

                System.out.print("Enter third string: ");
                name3 = keyboard.nextLine();

                b = name1.equals(name2);
                // Check if identical ignoring case

                b1 = name1.equalsIgnoreCase(name2);

                i = name1.compareTo(name2);

                if (i < 0)
                {
                    i1 = name1.compareToIgnoreCase(name3);

                    if (i1 < 0)
                    {
                        System.out.println(name1);
                        if (i1 > 0)
                        {
                            System.out.println(name3);
                            i2 = name2.compareToIgnoreCase(name3);
                            if (i2<0)
                            {
                                System.out.println(name2);
                                System.out.println(name3);
                            }
                            if (i2>0)
                            {
                                System.out.println(name3);
                                System.out.println(name2);
                            }
                        }
                    }
                }
                else if (i > 0)
                {

                    i1 = name2.compareToIgnoreCase(name3);

                    if (i1 < 0)
                    {
                        System.out.println(name2);
                        if (i1 > 0)
                        {
                            i2 = name1.compareToIgnoreCase(name3);
                            if (i2<0)
                            {
                                System.out.println(name1);
                                System.out.println(name3);
                            }
                            if (i2>0)
                            {
                                System.out.println(name3);
                                System.out.println(name1);
                            }
                        }
                    }
                }

            }
        }
    }
}

"line 25- illegal modifier for parameter first only final is permitted
line 12-illegal modifier for parameters only final is permitted
line 11-largest cannot be resorted to variable
line 11-syntax error on double @expected

Edited 4 Years Ago by dantheman4: corrected one of the errors

Each arg in a methods definition must have a type, there is not a list of names with a type.
See: http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html

A method can not be defined inside of another method. Code the ending "}" for one method before starting the definiton for the next method.

You should copy and paste the error messages, not type them in. The posted list of error messages has left off important information.

Edited 4 Years Ago by NormR1

Dan, one tip I find helpful for beginners is to label the end brackets. For example:

public class AnyClass {

    public static void main(String[] args) {
        ...

    }//main

}//class
Comments
Good idea. I use it a lot!!!
This article has been dead for over six months. Start a new discussion instead.