-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
请提供一个代码示例,并详细解释什么是不工作,你想要和你得到的错误 –