我需要知道如何對用戶輸入的數字列表進行計算。這是我的代碼到目前爲止,我失去了如何進行。我需要編寫一個代碼,詢問用戶是否想要手動輸入數字或從文件上傳。如果用戶選擇手動,我必須找到平均值,最小值,最大值和站點。開發。他們輸入的數字。任何幫助,將不勝感激如何在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
家庭作業是好的,但他們必須*至少*顯示一個嘗試,否則我們該如何知道如何幫助他們。我們不能替代教程/書籍和努力學習語言。問題被關閉 –