编程一小时2023.5.24

发布时间 2023-05-24 18:35:41作者: Verneyyx

1.

#include<iostream>
using namespace std;

int main()
{
float a = 0;//开始
float b = 0;//结束
float c = 0;//每公里价格
cout << "请输入每公里的价格:";
cin >> c;
cout << "MILEAGE REIMBURSEMENT CALCULATOR" << endl;
cout << "----------------------------------" << endl;
cout << "请输入开始读数:";
cin >> a;
cout << "请输入结束读数;";
cin >> b;
cout << "总里程为:" << b - a << endl;
cout << "每公里的价格为:" << c << "您的报销价格是:" << c * (b - a) << endl;

system("pause");
return 0;
}

2.

#include<iostream>
using namespace std;

int main()
{
float netbalance, payment, d1, d2, interestRate = 0;
float average, interest = 0;

cout << "请输入您的账单中显示的余额:" << endl;
cin >> netbalance;
cout << "请输入您已支付的款项金额:" << endl;
cin >> payment;
cout << "请输入计费周期内的天数:" << endl;
cin >> d1;
cout << "请输入计费周期前的付款天数:" << endl;
cin >> d2;
cout << "请输入利率:" << endl;
cin >> interestRate;

average = (netbalance*d1 - payment * d2) / d1;
interest = average * (interestRate / 100.0);
cout << "您的银行卡未付余额利息为:" << interest << endl;

system("pause");
return 0;
}

3.

#include<iostream>
using namespace std;

//输入产品的单价和订购的数量。 程序应该输出订单的总成本
//订单的前 100 项按单价收取,其余的按单价的 75%收取
int main()
{
float a = 0;//单价
int b = 0;//数量
double sum = 0;//总成本
cout << "请输入单价:";
cin >> a;
cout << "请输入订购的数量:";
cin >> b;
if (b > 100)
{
sum = a * 100 + 0.75*a*(b - 100);
}
else
{
sum = a * b;
}
cout << "总成本为:" << sum << endl;

system("pause");
return 0;
}