[英]Why is my code not working (java netbeans)?
i want the code to calculate the netpay formula.我想要代码来计算 netpay 公式。 This is the code I used, it has no errors in the program but when I run it, it just says build success and doesn't calculate.
这是我使用的代码,它在程序中没有错误,但是当我运行它时,它只是说构建成功并且不计算。
package com.mycompany.netpay;
public class NetPay {
public static void main(String[] args) {
}
double h = 40;
double i = 2.00;
double t = 0.22;
double w = 5.00;
double result = (h * w - i) - t * (h * w - i);
}
Typically you need your code within the method, not out of it.通常,您需要在方法中使用您的代码,而不是在方法之外。 Try this:)
尝试这个:)
package com.mycompany.netpay;
public class NetPay {
public static void main(String[] args) {
double h = 40;
double i = 2.00;
double t = 0.22;
double w = 5.00;
double result = (h * w - i) - t * (h * w - i);
// System.out.println(result);
}
}
You're not logging this out to the console or system however, so you may still not see a result.但是,您没有将其注销到控制台或系统,因此您可能仍然看不到结果。 Search "How to print to system in Java" for more information.
搜索“如何在 Java 中打印到系统”以获取更多信息。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.