【发布时间】:2020-06-25 15:17:28
【问题描述】:
我有一个任务要编写一个程序,该程序使用一个二维数组来显示根据年龄和他们将在那里的天数将您的孩子留在日托中心的费用。我不断收到一条错误消息,上面写着“找不到符号。变量:JOptionPane。”这会显示所有代码,包括该代码。它也显示相同的错误,但这次是“变量:整数”。 我错过了什么?
import java.util.Scanner;
public class DayCare
{
public static void main(String args[])
{
// Declare two-dimensional array here.
double pay[][] = {{30, 60, 88, 115, 140},
{26, 52, 70, 96, 120},
{24, 46, 67, 89, 110},
{22, 40, 60, 75, 88},
{20, 35, 50, 66,84}};
// Declare other variables.
int numDays;
int age;
String numDaysString;
String ageString;
int QUIT = 99;
Scanner input = new Scanner(System.in);
// This is the work done in the getReady() method
// Perform a priming read to get the age of the child.
ageString = JOptionPane.showInputDialog("Enter age of child: ");
age = Interger.parseInt(ageString);
while(age != QUIT)
{
// This is the work done in the determineRateCharge() method
// Ask the user to enter the number of days
numDaysString = JOptionPane.showInputDialog("Enter number of days: ");
numDays = Interger.parseInt(numDaysString);
// Print the weekly rate
System.out.println(" Pay is $" + pay[age][numDays]);
// Ask the user to enter the next child's age
ageString = JOptionPane.showInputDialog("Enter age of child: ");
age = Interger.parseInt(ageString);
}
// This is the work done in the finish() method
System.out.println("End of program");
System.exit(0);
} // End of main() method.
} // End of DayCare class.
【问题讨论】:
-
您没有导入 javax.swing.JOptionPane,并且您拼错了 Integer
-
哦,哎呀。这是一个关于整数的愚蠢错误。但是导入 javax.swing.JOptionpane 是什么意思?
-
import java.util.Scanner; -
导入java.util.Scanner的代码;已经在代码中,我不应该编辑它。我应该使用什么措辞代替 JOptionPane?
-
整数拼写错误。您没有使用扫描仪,请将其删除。您没有导入 javax.swing.JOptionPane
标签: java swing multidimensional-array