/*
* 实验三、类与对象定义初始化
* 1、有一圆形游泳池,现在需要在其周围建一圆形过道,并在其四周围上栅栏,
* 栅栏造价35元/米,过道造价为20元/平方米,求过道和栅栏的造价
* 2、有三个学生组队参加某比赛,每个学生信息包含准考证号,姓名,个人成绩,团队成绩
*
*/
/*
* 一游泳池需要围栅栏, 铺过道,
* 过道每平米价格 20
* 栅栏每米价格 35
* 过道宽度为 3
* 求建设 栅栏 过道 的总价分别是多少?
*/
#include <iostream>
#define PI 3.1415926
#define eachSqmPrice 20
#define eachMiterPrice 35
#define wide 3
using namespace std;
class swimminPool {
public:
double r;
public:
double totalPriceOfRoad(double r) {
double area = PI * (r + wide) * (r + wide) - PI * r * r;
double totalMoney = area * eachSqmPrice;
return totalMoney;
}
public:
double totalPriceOfBarrier(double r) {
double length = 2 * PI * r + 2 * PI * (r + 3);
double totalMoney = length * eachMiterPrice;
return totalMoney;
}
};
int main() {
swimminPool swimmingpool;
cout << "请输入游泳池的半径r:" << endl;
int r;
cin >> r;
double priceOfArea = swimmingpool.totalPriceOfRoad(r);
double priceOfLenght = swimmingpool.totalPriceOfBarrier(r);
cout << "过道总价为:" << priceOfArea << endl << "栅栏总价为:" << priceOfLenght << endl;
return 0;
}
/*
* 实验三、类与对象定义初始化
* 1、有一圆形游泳池,现在需要在其周围建一圆形过道,并在其四周围上栅栏,
* 栅栏造价35元/米,过道造价为20元/平方米,求过道和栅栏的造价
* 2、有三个学生组队参加某比赛,每个学生信息包含准考证号,姓名,个人成绩,团队成绩
*
*/
#include <iostream>
#include <cstring>
using namespace std;
class Student {
private:
string number;
string name;
public:
double score = 0;
double totalscore = 0;
public:
void setName(string Name) {
name = Name;
}
string getName() {
return name;
}
void setNumber(string Number) {
number = Number;
}
string getNumber() {
return number;
}
/*double totalScore(double score1, double score2, double score3) {
double totalscore = score1 + score2 + score3;
return totalscore;
}*/
};
int main() {
Student student1;
Student student2;
Student student3;
/*cout << "请输入学生准考证号和姓名:" << endl;
string number1;
string name1;
cin >> number1;
cin >> name1;
student1.setNumber(number1);
student1.setName(name1);
cout << "准考证为:" << student1.getNumber() << " 的学生姓名为:" << student1.getName() << endl;*/
/*for (int i = 1; i <= 3; i++) {
cout << "请输入学生 " << i << " 准考证号和姓名:" << endl;
string number1;
string name1;
cin >> number1;
cin >> name1;
student1.setNumber(number1);
student1.setName(name1);
cout << "请输入学生 " << i << " 的分数:" << endl;
int score1;
cin >> score1;
student1.score = score1;
cout << "准考证为:" << student1.getNumber() << " 的学生姓名为:" << student1.getName() << " 分数为:" << score1 << endl;
}*/
cout << "请输入 学生1 的准考证号:" << endl;
string number1;
cin >> number1;
cout << "请输入 学生1 的姓名:" << endl;
string name1;
cin >> name1;
student1.setNumber(number1);
student1.setName(name1);
cout << "请输入 学生1 的分数:" << endl;
int score1;
cin >> score1;
student1.score = score1;
cout << "准考证号为:" << student1.getNumber() << " 的学生姓名为:" << student1.getName() << " 分数为:" << student1.score << endl << endl;
cout << "请输入 学生2 的准考证号:" << endl;
string number2;
cin >> number2;
cout << "请输入 学生2 的姓名:" << endl;
string name2;
cin >> name2;
student2.setNumber(number2);
student2.setName(name2);
cout << "请输入 学生2 的分数:" << endl;
int score2;
cin >> score2;
student2.score = score2;
cout << "准考证号为:" << student2.getNumber() << " 的学生姓名为:" << student2.getName() << " 分数为:" << student2.score << endl << endl;
cout << "请输入 学生3 的准考证号:" << endl;
string number3;
cin >> number3;
cout << "请输入 学生3 的姓名:" << endl;
string name3;
cin >> name3;
student3.setNumber(number3);
student3.setName(name3);
cout << "请输入 学生3 的分数:" << endl;
double score3;
cin >> score3;
student3.score = score3;
cout << "准考证号为:" << student3.getNumber() << " 的学生姓名为:" << student3.getName() << " 分数为:" << student3.score << endl << endl;
cout << "团队成绩为:" << endl;
double totalscore = student1.score + student2.score + student3.score;
cout << totalscore << endl;
return 0;
}