c语言编程计算学生绩点视频,求----计算学分绩点的C语言程序

#include

#include

#define MAX_STUDENT 40

struct CStudent

{

private:

char m_name[20];

int m_age;

char m_sex[10];

double m_math;

double m_english;

double m_chinese;

public:

CStudent()

{

}

CStudent(char* name, int age, char* sex )

{

strcpy(m_name,name);

m_age = age;

strcpy(m_sex,sex);

}

void SetName(char* name )

{

strcpy(m_name,name);

}

void SetAge(int age)

{

m_age = age;

}

void SetSex(char* sex)

{

strcpy(m_sex,sex);

}

void ShowName()

{

cout << m_name << endl;

}

void ShowAge()

{

cout << m_age << endl;

}

void ShowSex()

{

cout << m_sex << endl;

}

void SetEnglish(double english)

{

m_english = english;

}

void SetMath(double math)

{

m_math = math;

}

void SetChinese(double chinese)

{

m_chinese = chinese;

}

double GetMathScore()

{

double dblScore;

if (m_math < 60) {

dblScore = 0;

}

else if (m_math >=60 && m_math < 70) {

dblScore = 1;

}

else if (m_math >=70 && m_math < 80) {

dblScore = 2;

}

else if (m_math >=80 && m_math < 90) {

dblScore = 3;

}

else if (m_math >=90 && m_math < 100) {

dblScore = 4;

}

else if (100 == m_math) {

dblScore = 5;

}

return dblScore;

}

double GetChineseScore()

{

double dblScore;

if (m_chinese < 60) {

dblScore = 0;

}

else if (m_chinese >=60 && m_chinese < 70) {

dblScore = 1;

}

else if (m_chinese >=70 && m_chinese < 80) {

dblScore = 2;

}

else if (m_chinese >=80 && m_chinese < 90) {

dblScore = 3;

}

else if (m_chinese >=90 && m_chinese < 100) {

dblScore = 4;

}

else if (100 == m_chinese) {

dblScore = 5;

}

return dblScore;

}

double GetEnglishScore()

{

double dblScore;

if (m_english < 60) {

dblScore = 0;

}

else if (m_english>=60 && m_english < 70) {

dblScore = 1;

}

else if (m_english >=70 && m_english < 80) {

dblScore = 2;

}

else if (m_english >=80 && m_english < 90) {

dblScore = 3;

}

else if (m_english >=90 && m_english < 100) {

dblScore = 4;

}

else if (100 == m_english) {

dblScore = 5;

}

return dblScore;

}

};

void main()

{

CStudent student[MAX_STUDENT];

int index = 0;

char c = 'y';

char name[20];

char sex[10];

double english,math,chinese;

int age;

while (c == 'y' || c == 'Y') {

cout << "输入学生姓名:" << endl;

cin >> name;

student[index].SetName(name);

cout << "输入学生年龄:" << endl;

cin >> age;

student[index].SetAge(age);

cout << "输入学生性别:" << endl;

cin >> sex;

student[index].SetSex(sex);

cout << "输入英语成绩:" << endl;

cin >> english;

student[index].SetEnglish(english);

cout << "输入数学成绩:" << endl;

cin >> math;

student[index].SetMath(math);

cout << "输入语文成绩:" << endl;

cin >> chinese;

student[index].SetChinese(chinese);

index ++;

cout << "是否继续输入(Y/N)" << endl;

cin >> c;

}

cout << "=========================打印成绩表================================"<< endl;

for(int j = 0; j < index; j ++)

{

cout << "姓名为:" << endl;

student[j].ShowName();

cout << "年龄为:" << endl;

student[j].ShowAge();

cout << "性别为:"<< endl;

student[j].ShowSex();

cout << "英语学分为:" << student[j].GetEnglishScore() << endl;

cout << "数学学分为:" << student[j].GetMathScore() << endl;

cout << "语文学分为:" << student[j].GetChineseScore() << endl;

cout << "总学分:" << student[j].GetMathScore() * 3 + student[j].GetEnglishScore() * 1.5 + student[j].GetChineseScore() * 2 << endl;

cout <

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值