I can't get this program correct. Someone please help me.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sachu1996
    New Member
    • Jun 2010
    • 3

    I can't get this program correct. Someone please help me.

    import java.io.*;
    public class addsub
    {
    public static void main(String args[])throws IOException
    {
    int a,b,s,d;
    s=0;
    d=0;
    InputStreamRead er read=new InputStreamRead er(System.in);
    BufferedReader in=new BufferedReader( read);
    System.out.prin tln("Enter two numbers");
    a=Integer.parse Int(in readLine());
    b=Integer.parse Int(in readLine());
    s=a+b;
    d=a-b;
    System.out.prin tln("Sum="+s);
    System.out.prin tln("Difference ="+d);
    }
    }
  • rotaryfreak
    New Member
    • Oct 2008
    • 74

    #2
    lol your program works perfectly fine :) you just need to add the "." between your variable and your method call, so it should be:
    a=Integer.parse Int(in.readLine ());
    b=Integer.parse Int(in.readLine ());

    also fyi, using an editor will help you code because the editor will automatically pick up any syntactical errors. eclipse and netbeans are just some of the editor that can be used with java

    Comment

    Working...