*******Guys my output is correct but the computers checks it wrong, any suggestions about this?********
Write a program that takes two integers as input(one per line) and prints their sum as output.
For example,
For the input provided as follows:
2
3
The output of the program will be:
5
Provided code
Import java.io.*;
Public class Main
{
Public static void main(String [] args) throws java.lang.Exception{
String line;
DataInputStream in = new DataInputStream(System.in);
While((line=in.readLine())!=null){
}
}
}
}My Personal Code
package a;
//The solutions should be written, for compiler compatibility : j2se jdk 8u51
import java.io.*;
public class Main
{
public static void main (String[] args) throws java.lang.Exception
{
//use the following code to fetch input from console
String line;int first; int second; int total; int i;
DataInputStream in = new DataInputStream(System.in);
System.out.println("For the input provided as follows: "+"\n");
while((line=in.readLine())!=null)
{
int game []= new int[2];
int came [] = new int[2];
for( i = 0;i<2;i++) {
game[i]=Integer.parseInt(line);
came[i]=Integer.parseInt(in.readLine());
System.out.println(game[i]);
System.out.println(came[i]);
break;
}
for( i = 0;i<2;i++) {
if(game[i]<0 && came[i]<0) {
total = game[i]+came[i];
System.out.println("The output of the program will be:" +"\n"+total);
break;
}
else if(game[i]>0 && came[i]<0) {
total = game[i]+came[i];
System.out.println("The output of the program will be:" +"\n"+total);
break;
}
else if(game[i]<0 && came[i]>0) {
total = game[i]+came[i];
System.out.println("The output of the program will be:" +"\n"+total);
break;
}
else if(game[i]>0 && came[i]>0) {
total = game[i]+came[i];
System.out.println("The output of the program will be:" +"\n"+total);
break;
}
else if (game[i]==0 && came[i]==0) {
total = game[i]+came[i];
System.out.println("The output of the program will be:" +"\n"+total);
break;
}
}
}
}
}Errors from the computer checker
0 out of 4 Test case Failed
- Two positive integers
- Two negative integers
- one positive and one negative integer.
- corner case for zero








