-3
我是編程新手,而且很難創建一個程序,該程序將從for循環中的數組收集的數據顯示到表中。我能夠收集數據,但無法存儲並在之後顯示。有什麼想法嗎?顯示錶格的循環
這是我寫
import java.util.Scanner;
//Fahrenheit to Celsius converter
public class CelsiusConversion
{
public static void Celsius(String[] args)
{//Open method 1
int num;
double [] temps;
double fahrenheit;
Scanner input = new Scanner(System.in);
System.out.println("Enter the amount of numbers you wish to average: ");
num = input.nextInt();
while (num<1)
{
System.out.println("You did not enter a number greater than zero. Please enter a number greater than zero:");
num = input.nextInt();
}
temps = new double [num];
for (int t = 0; t <num; t++)
{
System.out.println("Enter temperature " + (t+1) + " in Fahrenheit:");
temps[t] = input.nextDouble();
System.out.println("Please confirm the temperature in Fahrenheit");
fahrenheit = input.nextDouble();
double celsius = 5.0/9*(fahrenheit - 32);
System.out.println(fahrenheit + " in Celsius is " + celsius + ".");
}
}//Close method 1
}
我想顯示的外部數據的循環,如果可能的 – Priice
後的你已經嘗試過的代碼。並且請把它作爲編輯而不是評論上的問題。 – Julian
請提供一個代碼示例,並詳細解釋什麼是不工作,你想要和你得到的錯誤 –