英文:
I can't seem to figure out what to do next. It keeps saying "Not a statement"
问题
// 我已经调试好了一组代码,除了最后一行,它不断告诉我它是“不是一个语句”,我对接下来该做什么感到困惑。如果有人能在这里帮助我,我会非常感谢。
[错误信息的屏幕截图][1]
这里也是图片中的代码。
// 这个程序计算一个商品的折扣后销售价格
// 原价为$59,折扣为20%。
import java.util.Scanner; // 需要用到 Scanner 类
public class Discount
{
public static void main(String[] args)
{
// 声明变量以保存原价、折扣金额和销售价格
double regularPrice = 59.0;
double discount; // 声明折扣变量
double salePrice;
// 创建一个 Scanner 对象以读取输入
Scanner keyboard = new Scanner(System.in);
// 获取原价
System.out.print("输入原价:");
regularPrice = keyboard.nextDouble();
// 计算20%折扣金额
discount = regularPrice * 0.20;
// 通过从原价中减去折扣来计算销售价格
salePrice = regularPrice - discount;
// 显示结果
System.out.println("原价:$" + regularPrice);
System.out.println("折扣金额:$" + discount);
System.out.println("销售价格:$" + salePrice);
}
}
[1]: https://i.stack.imgur.com/hQAQm.png
英文:
I was given a set of code to debug and I have it all debugged except for one last line that keeps telling me that it is "Not a statement" and I am just confused about what to do next. If anyone can help me here it would be much appreciated.
Here is also the code that is in the picture.
// This program calculates the sale price of an
// item that is regularly priced at $59, with
// a 20 percent discount subtracted.
import java.util.Scanner; // Needed for the Scanner class
public class Discount
{
public void main(String[] args)
{
Variables to; hold the; regular price, the;
amount of; a discount, and; the sale; price;
double regularPrice = 59.0;
double salePrice;
// Create a Scanner object to read input
scanner keyboard = new Scanner(System.input);
// Get the regular price
System.out.print("Enter regular price");
regularPrice = key.next();
// Calculate the amount of a 20% discount.
discount = regularPrice * 0.20;
// Calculate the sale price by subtracting
// the discount from the regular price.
salePrice = regularPrice - discount;
// Display the results.
system.println("Regular price: $ + regularprice");
system.println("Discount amount: $ + discount");
system.println("Sale price: $ + total");
}
}
答案1
得分: 2
变量用于保存常规价格、折扣金额和销售价格。
这两行必须是注释。
英文:
Comment these two lines:
Variables to; hold the; regular price, the;
amount of; a discount, and; the sale; price;
They have to be comments.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论