Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: What's wrong with this program?

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default What's wrong with this program?

    I keep getting this error:
    "
    Main.java:8: error: ';' expected
    System out.println("input A:");
    ^
    1 error
    "

    Here's the program:
    import java.io.*;
    import java.util.Scanner;
    class Main {
      public static void main (String[] args) throws Exception {
    System.out.println("hello world");
        Scanner asd = new Scanner(System.in);
        System.out.println("(Ax + B)^2");
        System out.println("input A:");
        int A = asd.nextInt(); 
        System.out.println("input B:");
        int B = asd.nextInt();
        int nA = A*A;
        int nB = A*B*2;
        int C = B*B; 
        System.out.println("("+nA+"x^2 + " + nB +"x + " + C ); 
     
      }
    }
    I've already checked for the lack of semicolons, so does anyone know what might be causing it? Any help would be appreciated, I'm using an iPhone app instead of what I ordinarily use, which is netbeans.
    Last edited by jtm429; November 30th, 2013 at 02:51 PM. Reason: Code tags


  2. #2
    Junior Member
    Join Date
    Jul 2013
    Posts
    24
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: What's wrong with this program?

    You forgot the dot between System and out.
    Also post code inside code tags:
    import java.io.*;
    import java.util.Scanner;
    class Main {
        public static void main (String[] args) throws Exception {
            System.out.println("hello world");
            Scanner asd = new Scanner(System.in);
            System.out.println("(Ax + B)^2");
            System.out.println("input A:");
            int A = asd.nextInt(); 
            System.out.println("input B:");
            int B = asd.nextInt();
            int nA = A*A;
            it nB = A*B*2;
            int C = B*B; 
            System.out.println("("+nA+"x^2 + " + nB +"x + " + C ); 
        }
    }

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

    jtm429 (November 30th, 2013)

  4. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: What's wrong with this program?

    Okay thanks, it works now, and I will. I just got this account today, so I wasn't sure how it was supposed to be done.

  5. #4
    Junior Member
    Join Date
    Jul 2013
    Posts
    24
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default Re: What's wrong with this program?

    Glad, I could help.

Similar Threads

  1. What's wrong with my code? Card Program.
    By AustinStanley in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 14th, 2013, 07:36 PM
  2. please tell me what's wrong in my program
    By deepani in forum What's Wrong With My Code?
    Replies: 1
    Last Post: January 31st, 2013, 06:58 AM
  3. Program returning wrong values.
    By cam25 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: June 11th, 2012, 11:59 PM
  4. What's wrong with simple Scanner program?
    By SV25 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 21st, 2011, 07:05 AM
  5. whats wrong with my program??
    By jrodriguo in forum What's Wrong With My Code?
    Replies: 4
    Last Post: May 11th, 2010, 06:16 AM

Tags for this Thread