《quantitative finance with cpp》阅读笔记6---计算公司的净利润
作者:yunjinqi 类别:
日期:2023-11-24 11:08:56
阅读:497 次 消耗积分: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;
}