|
|
вернуться в форумwhat is wrong with this code! someone help me please 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 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 |
|
|