import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class addition  {
	
	
	
	 
	 InputStreamReader ins=new InputStreamReader(System.in);
     BufferedReader br=new BufferedReader(ins);
    int a,b,c;
    
    public addition()
    {
         
        
    	 int a=Integer.parseInt(br.readLine());
    	 int b=Integer.parseInt(br.readLine());
    	 System.out.println("a="+a);
    	 System.out.println("b="+b);
    	 c=a+b;
    	 System.out.println("c="+c);
    }
    public static void main(String args[])
    {
    	
    	addition a =new addition();
    	
    }

    	 
    	 
    	 
    	 
    	 
    	 
         }

Recommended Answers

All 4 Replies

where s the mistake??

how to do this???

sorry I can't hepl you with that (so little bit knowledge ...), but in forums history is lots of topic about that

I have tried to make the code simplier for you to understand easily...
I debugged code and removed the errors...
First of all while reading data you must put your code within try and catch block....

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class pat {

  public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String number;
    int c;
try{
     int a=Integer.parseInt(br.readLine());
    	 int b=Integer.parseInt(br.readLine());
    	 System.out.println("a="+a);
    	 System.out.println("b="+b);
    	 c=a+b;
    	 System.out.println("c="+c);



   }
catch (IOException e) {
System.out.println("Error");
}
    
  }
 
}

PS-If your problem is solved ...mark the thread as solved..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.