【发布时间】:2015-03-11 01:53:27
【问题描述】:
我是 Java 编程新手。我试图编写一个将温度从华氏温度转换为摄氏温度的代码,反之亦然,并且在解析错误时到达了文件的末尾。那我该怎么做才能解决它
package fahrenheittocelsius;
import java.util.Scanner;
public class Fahrenheittocelsius
{
public static void main(String[] args)
{
String firstchoice ;
String ftc ="fahrenheit to celsuis" ;
String ctf = "celsius to fahrenheit";
System.out.println("Do you want to convert from 'fahrenheit to celsuis' or 'celsius to fahrenheit' ");
Scanner firstscan = new Scanner(System.in);
firstchoice = firstscan.nextLine();
if (firstchoice.equals(ftc) );
{
System.out.println("Write in the temperature in Fahrenheit that you want to convert it to celsius ");
Scanner scan1 = new Scanner(System.in);
double f ;
f = scan1.nextDouble();
double c ;
c= (5/9.0)* (f-23) ;
System.out.println("the temperature in celsius is " + c );
}
if (firstchoice.equals(ctf) );
{
System.out.println("Write in the temperature in celsuis that you want to convert it to fahrenheit ");
Scanner scan2 = new Scanner(System.in);
double CC ;
double FF ;
CC = scan2.nextDouble();
FF= (CC * 2) + 30 ;
System.out.println("the temperature in celsius is " + FF);
}
}
【问题讨论】:
-
请在问题中包含您遇到的完整错误。
-
您缺少结束语
}。如果你愉快地格式化你的代码,你会发现这很容易被发现。如果您没有使用可以为您格式化代码并适当缩进的 IDE 或编辑器,我建议您现在就开始。 -
嗨 celeo,我正在使用 netbeans,在最后一行出现一个红点,它说在解析时到达了文件的末尾,我不知道这是什么意思,我应该怎么做才能修复它。 ..
-
乔恩我应该把丢失的地方放在哪里}
-
阿里,你觉得应该去哪里?学习编程的一部分是解决问题。查找您将
{放在哪里,并找出}应该放在哪里。