import javax.swing.JOptionPane;
public class Project3
{
public static void main ( String [] args )
{
double charges, savings_B, savings_C;
char pakge;
int hours;
String input;
input = JOptionPane.showInputDialog("Please enter the letter of the package the customer has purchased(ex: A,B or C): ");
pakge = Char.parseChar(input); error: cannot find symbol
input = JOptionPane.showInputDialog("Please enter the number of hours that were used: ");
hours = Int.parseInt(input); error: cannot find symbol
if (pakge == 'A')
{
if (hours <= 10)
{
charges = 9.95;
savings_B = charges - 13.95;
savings_C = charges - 19.95;
}
else if (hours > 10 && hours <=20)
{
charges = 9.95 + 2*(hours - 10);
savings_B = charges - 13.95;
savings_C = charges - 19.95;
}
else
{
charges = 9.95 + 2*(hours - 10);
savings_B = charges - (13.95 + 1*(hours - 20));
savings_C = charges - 19.95;
}
JOptionPane.showMessageDialog(null, "The total charges are: " + charges);
}
}
}
要怎么修改呢?
求助,Java代码调试出现error: cannot find symbol,怎么修改?
答案:3 悬赏:40
解决时间 2021-04-28 06:54
- 提问者网友:心裂忍耐
- 2021-04-27 09:53
最佳答案
- 二级知识专家网友:一只傻青衣
- 2021-04-27 11:33
java是区分大小写的,试试把下面错误改正一下。
string 应为string
system.out.println应为system.out.println
string 应为string
system.out.println应为system.out.println
全部回答
- 1楼网友:眠于流年
- 2021-04-27 13:47
double charges, savings_B, savings_C;
char pakge;
int hours;
String input;
input = JOptionPane.showInputDialog("Please enter the letter of the package the customer has purchased(ex: A,B or C): ");
pakge = input.toCharArray()[0]; // 这样修改
input = JOptionPane.showInputDialog("Please enter the number of hours that were used: ");
hours = Integer.parseInt(input); // 这样修改
if (pakge == 'A')
{
if (hours <= 10)
{
charges = 9.95;
savings_B = charges - 13.95;
savings_C = charges - 19.95;
}
else if (hours > 10 && hours <=20)
{
charges = 9.95 + 2*(hours - 10);
savings_B = charges - 13.95;
savings_C = charges - 19.95;
}
else
{
charges = 9.95 + 2*(hours - 10);
savings_B = charges - (13.95 + 1*(hours - 20));
savings_C = charges - 19.95;
}
JOptionPane.showMessageDialog(null, "The total charges are: " + charges);
- 2楼网友:何必打扰
- 2021-04-27 12:31
pakge = Char.parseChar(input);
hours = Int.parseInt(input);
这2个是c#的用法。
应改为:
pakge = input.toCharArray()[0];
hours = Integer.parseInt(input);
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息!
大家都在看
推荐信息