ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1000. A+B Problem

what is wrong with this code! someone help me please
Posted by Brunno de Godoy Amorim 14 May 2011 05:24
import java.util.Scanner;

public class Sum{

public static void main(String tev[]){

Scanner input = new Scanner (System.in);

Integer num1;

Integer num2;

Integer resul = 0;

System.out.println("enter a number");
num1 = input.nextInt();


System.out.println("enter a number");
num2 = input.nextInt();

resul = (num1 + num2);

System.out.printf("%d + %d = %d",num1,num2,resul);


}
}
Re: what is wrong with this code! someone help me please
Posted by AterLux 14 May 2011 15:39
System.out.println("enter a number");
...
System.out.println("enter a number");
...
System.out.printf("%d + %d = %d",num1,num2,resul);

you asked to output only single number without any other text, including input prompt. Like this

System.out.println(resul);

Testing system can't read your "enter a number"! It not so clever ;)

Edited by author 14.05.2011 15:40