gpt4 book ai didi

java - 如何让我的java程序输出答案?

转载 作者:行者123 更新时间:2023-12-02 05:24:59 24 4
gpt4 key购买 nike

我是 Java 新手,我的类(class)有一项家庭作业,需要一些帮助。我完成了除了输出之外的所有内容,我似乎无法让程序产生答案。

    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;
}
}

最佳答案

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 is :"+result);
}
}

关于java - 如何让我的java程序输出答案?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26137469/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com