我需要知道如何对用户输入的数字列表进行计算。这是我的代码到目前为止,我失去了如何进行。我需要编写一个代码,询问用户是否想要手动输入数字或从文件上传。如果用户选择手动,我必须找到平均值,最小值,最大值和站点。开发。他们输入的数字。任何帮助,将不胜感激如何在JAVA中对用户输入的数字列表进行计算?
import java.io.*;
public class computation {
//main method starts
public static void main (String[] args) throws Exception {
//create text input reader
InputStreamReader get = new InputStreamReader(System.in);
BufferedReader got = new BufferedReader(get);
//create a text printer
PrintWriter send = new PrintWriter(System.out,true);
//defining a string type variable for user input
String answer1;
//asks the user if they want to input data from keyboard
String question = "Do you want to input data manually? Enter y or n";
send.println(question);
//system reads user input
answer1 = got.readLine();
if (answer1.equals("y")) {
send.println("Enter numbers separated by spaces");
String datacurrent = got.readLine();
} //end of "y" if
if (answer1.equals("n")) {
send.println("Enter the path of your data file");
} //end of "n" if
} //end of main method
} //end of class computation
''我需要编写一个代码,询问用户是否想手动输入数字或从文件上传。如果用户选择手动,我必须找到平均值,最小值,最大值和立场。dev。的数字,他们输入。任何帮助,将不胜感激 - 任何第一次尝试,你也将赞赏,请至少尝试。 –
这似乎是一个家庭作业的问题,一般皱眉在这里。 – hexafraction
家庭作业是好的,但他们必须*至少*显示一个尝试,否则我们该如何知道如何帮助他们。我们不能替代教程/书籍和努力学习语言。问题被关闭 –