《quantitative finance with cpp》阅读笔记6---计算公司的净利润
作者:yunjinqi   类别:    日期:2023-11-24 11:08:56    阅读:149 次   消耗积分:0 分    
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
    double revenue;
    double costs;
    double tax;
 
    cout << "What is the revenue?\n";
    cin >> revenue;
    cout << "What were the costs?\n";
    cin >> costs;
    cout << "What is the tax rate (%)?\n";
    cin >> tax;
 
    double grossProfit = revenue-costs;
    double netProfit;
    if (grossProfit>0) {
        netProfit = grossProfit * (1 - 0.01*tax);
    } else {
        netProfit = grossProfit;
    }
 
    cout << "Net profit is ";
    cout << netProfit << "\n";
    return 0;
}


版权所有,转载本站文章请注明出处:云子量化, http://www.woniunote.com/article/371
上一篇:《quantitative finance with cpp》阅读笔记5---cpp根据不同考试成绩输出不同字符
下一篇:《quantitative finance with cpp》阅读笔记7---bs看涨期权定价公式两种cpp代码