import java.util.*;
public class AllowedToRide
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Height (cm)? ");
double height = keyboard.nextDouble();
System.out.println("Gender (male or female? ");
String gender = keyboard.next();
String allowed;
if(gender.equalsIgnoreCase("female"))
{
System.out.println("Pregnant (yes or no)? ");
if(pregnant.equalsIgnoreCase("yes"))
{
allowed="No";
}
else
{
allowed="Yes";
}
}
if(height<110)
{
allowed="No";
}
else
{
allowed="Yes";
}
}
System.out.println("Allowed to ride (yes or no)? " + allowed);
}
我需要为uni完成此操作,并且我无法弄清楚编译时的错误。它们粘贴在下面:
U:\ progEnv \ assignment \ AllowedToRide.java:48:错误: 预期的System.out.println(&#34;允许骑(是或否)?&#34; + 成本); ^
U:\ progEnv \ assignment \ AllowedToRide.java:48:错误:非法启动 输入System.out.println(&#34;允许骑(是或否)?&#34; +费用); ^
U:\ progEnv \ assignment \ AllowedToRide.java:48:错误:&#39;)&#39;预计
System.out.println(&#34;允许骑(是或否)?&#34; +费用); ^U:\ progEnv \ assignment \ AllowedToRide.java:48:错误:&#39;;&#39;预计
System.out.println(&#34;允许骑(是或否)?&#34; +费用); ^U:\ progEnv \ assignment \ AllowedToRide.java:48:错误:非法启动 输入System.out.println(&#34;允许骑(是或否)?&#34; +费用); ^
U:\ progEnv \ assignment \ AllowedToRide.java:48:错误: 预期的System.out.println(&#34;允许骑(是或否)?&#34; + 成本); ^
U:\ progEnv \ assignment \ AllowedToRide.java:48:错误:&#39;;&#39;预计
System.out.println(&#34;允许骑(是或否)?&#34; +费用); ^U:\ progEnv \ assignment \ AllowedToRide.java:49:错误:已达到结束 解析时的文件} ^
8个错误
答案 0 :(得分:0)
您尚未声明变量pregnant
且您的System.out.println("Allowed to ride (yes or no)? " + cost);
不在主方法中。
答案 1 :(得分:0)
不确定您的要求是什么,以下代码可以正常工作。希望这会有所帮助。
"\windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" /tlb Microsoft.Office.Tools.Common.v4.0.Utilities.dll