-2 java
我收到错误:非法开始表达,不知道如何解决这个问题.这是我需要用指南编写的程序的所有声明.该计划旨在计算船的成本.提前致谢!
import java.util.Scanner;
public class boat
{
public static void main(String[] args)
{
//declarations
....
double depreciationYear1 = bookValueBeginningYear1 * (2 * 100% / 3);
^
double bookValueBeginningYear2 = bookValueBeginningYear1 - depreciationYear1;
double depreciationYear2 = bookValueBeginningYear2 * (2 * 100% / 3);
^
double bookValueBeginningYear3 = bookValueBeginningYear2 - depreciationYear2;
double depreciationYear3 = bookValueBeginningYear3 * (2 * 100% / 3);
.... ^
double exciseTaxYear1 = 90% * boatPrice/1000 * 25;
^
double exciseTaxYear2 = 80% * boatPrice/1000 * 25;
^
double exciseTaxYear3 = 70% * boatPrice/1000 * 25;
.... ^
double insuranceYear1 = boatPrice * 1% + bookValueBeginningYear1* 3%;
^
double insuranceYear2 = boatPrice * 1% + bookValueBeginningYear2* 3%;
^
double insuranceYear3 = boatPrice * 1% + bookValueBeginningYear3* 3%;
.... ^
Run Code Online (Sandbox Code Playgroud)
(2 * 100% / 3);
Run Code Online (Sandbox Code Playgroud)
改为使用:
(2 * 100 / 3); // Just remove the % from all the statement.
Run Code Online (Sandbox Code Playgroud)
因为您一次使用两个运算符(%,/).
这是代码中所有语句的错误,您已标记.
它%是java中的模数运算符,用于计算两个数的余数10%4 is 2.考虑到百分比,你可能会感到困惑.
| 归档时间: |
|
| 查看次数: |
84 次 |
| 最近记录: |