我是新來的java和我的班有一個家庭作業,我需要一點幫助。除了輸出外,我完成了所有的任務,我似乎無法讓程序產生答案。如何讓我的java程序輸出答案?
import java.util.Scanner;
public class HomeworkScanner
{
public static void main(String args[])
{
int x, y, z, a, result;
Scanner Keyboard;
Keyboard = new Scanner(System.in);
System.out.println("a = (x + y) * z");
System.out.println("Enter first number for x:");
x = Keyboard.nextInt(); //
System.out.println("Enter second number for y:");
y = Keyboard.nextInt(); //
System.out.println("Enter third number for z:");
z = Keyboard.nextInt(); //
result=a=(x + y) * z;
}
}
'System.out.println(result)'? – 2014-10-01 08:47:17
只是打印結果值,實際上是不打印它只是評估和存儲,但在觀看輸出打印它,因爲它是在上面的評論中提到 – santhosh 2014-10-01 08:50:54