简体   繁体   English

"我是 java\/coding 的新手,我的教授希望我创建一个计算数学函数的应用程序,但我一次只能做一个"

[英]I'm new to java/coding and my professor wants me to create an application that calculates math functions but I can't do more than one at once

Im trying to set up a program that can do multiple math functions and I can get the first function to work but I have no idea how to set it up so that it can do more than one.我试图设置一个可以执行多个数学函数的程序,我可以让第一个函数工作,但我不知道如何设置它,以便它可以做多个。 The assignment is Utilizing the Java language fundamentals covered in class, create an application that correctly calculates the math functions and produces the expected output.作业是利用课堂中涵盖的 Java 语言基础知识,创建一个能够正确计算数学函数并产生预期输出的应用程序。 Each number must be represented as a variable.每个数字都必须表示为一个变量。

public class main
{

    public static void main(String[] args)
    {
        int x = -5;
        int y = 8;
        int c = 6;
        int z = x + y * c;
        System.out.println("for the equation ' x + y * c'the sum is" + z);
    }
}

First, I would recommend that you provide a little bit more information about what is being asked of you, since I do not know which math functions you are being asked to implement.首先,我建议你提供更多关于你被问到什么的信息,因为我不知道你被要求实现哪些数学函数。 Also, the key word here would be functions.此外,这里的关键词是功能。 I am assuming that your instructor wants you to implement a function that does the specific math problem (adding, subtracting, etc) but I am not sure.我假设您的讲师希望您实现一个解决特定数学问题(加法、减法等)的函数,但我不确定。 In that case, you would have to declare multiple functions in your program, and then call them in the main function.在这种情况下,您必须在程序中声明多个函数,然后在主函数中调用它们。 Right now, you are simply writing code inside of the main function, which is why you are unable to do more than one math function at once.现在,您只是在 main 函数中编写代码,这就是为什么您不能同时执行多个数学函数的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM