所以我使用JOptionPane创建程序并使用do while。我只有1个错误
令牌上的语法错误")",;在此令牌之后预期 在" while(select> 5)
上表达
这是我的代码
public class Labwork2ABUEL {
public static void main(String[] args)
{
float num;
String choice, input, numInput;
int select, area, width, height, n, i, f;
double radius, area1;
Object[] options = {"Yes", "No"};
do {
choice = JOptionPane.showInputDialog("Main Menu " +
"\n 1. COMPUTE FOR AN AREA OF CIRCLE"
+ "\n 2. COMPUTE FOR AN AREA OF SQUARE"
+ " \n 3. COMPUTE FOR AN AREA OF RECTANGLE"
+ "\n 4. COMPUTE FOR A FACTORIAL OF A NUMBER"
+ "\n 5. EXIT THE PROGRAM");
}
while (select > 5)
{
choice = JOptionPane.showInputDialog("Enter only 1-5!" +
"\n Main Menu +"
+ "\n 1. COMPUTE FOR AN AREA OF CIRCLE"
+ "\n 2. COMPUTE FOR AN AREA OF SQUARE"
+ "\n 3. COMPUTE FOR AN AREA OF RECTANGLE"
+ "\n 4. COMPUTE FOR A FACTORIAL OF A NUMBER"
+ "\n 5. EXIT THE PROGRAM");
}
if (select == 1)
{
choice = JOptionPane.showInputDialog("Enter Radius", "Circle Area Input");
radius = Double.parseDouble(input);
area1 = Math.PI * Math.pow(radius, 2);
String message = "Area of Circle: " + area1;
String title = "Circle Area Output";
JOptionPane.showMessageDialog(null, message, title, select);
答案 0 :(得分:1)
在while (some condition);
循环结束}
后,您遗失了do
。
或者,您在;
之后错过while (select > 5)
。
但在此之后,您将获得与未初始化变量相关的大量错误,例如select
。还有一大堆逻辑错误,比如select
循环中没有更改while (select > 5)
。
答案 1 :(得分:0)
do {
choice = JOptionPane.showInputDialog("Main Menu " +
"\n 1. COMPUTE FOR AN AREA OF CIRCLE"
+ "\n 2. COMPUTE FOR AN AREA OF SQUARE"
+ " \n 3. COMPUTE FOR AN AREA OF RECTANGLE"
+ "\n 4. COMPUTE FOR A FACTORIAL OF A NUMBER"
+ "\n 5. EXIT THE PROGRAM");
}while(some condition);//missing it.