我正在尝试创建一个简单的程序,它将给我23%的2500000我不能让它工作,无论我改变什么。我正在使用记事本++

时间:2016-10-16 18:37:10

标签: javascript

var TotalSales = $2, 500, 000;
var Profit = (TotalSales * 23 / 100);

console.log {
    "annual profit:" + math.floor {
        Profit
    };

3 个答案:

答案 0 :(得分:1)

在Javascript中,您无法使用

编写数字
  • 多个,(或任何,就此而言)
  • 像$
  • 这样的单位

您可以在Javascript here

中详细了解数字

此外,当您定义一项功能时,您使用的是{,但当您调用一项功能时,例如console.log()您使用(。您可以了解有关函数here的更多信息。

所以代码需要看起来像这样:



 var TotalSales = 2500000;
    var Profit = (TotalSales * (23 / 100));
    
    console.log("annual profit: $" + Math.floor(Profit));




答案 1 :(得分:0)

不要使用' $'和','同时为变量

赋值
<script>
    var TotalSales = 2500000; 
    var Profit = (TotalSales * 23 / 100);
    console.log ("annual profit:" + Profit);
</script> 

答案 2 :(得分:0)

java代码:

    double TotalSales = 2500000;
    double profit = (TotalSales * 23 / 100);
    int floorProfit = (int) Math.round(profit);
    System.out.println("annual profit: "+floorProfit);