- 分享
- 0
- 人气
- 0
- 主题
- 26
- 帖子
- 2343
- UID
- 97728
- 积分
- 2082
- 阅读权限
- 20
- 注册时间
- 2007-9-6
- 最后登录
- 2017-11-23
- 在线时间
- 3789 小时
|
这个是我的assignment来的~就送给想学c++的人看看吧~
不过还是有很多缺点因为我懂得不多~最严重的是格子~不会allign所以那里很难看~
然后输入限制也是没弄
因为题目需求之好弄成那样~以下是编码~
题目是输入5个分数+学生名字和ID然后算出等级~再加一些bla bla bla....
内容就不多说~给你们慢慢摸@@
新手看一看学学吧~
注:其实想用array不过老师说做那个没分因为当时没教到所以变得很普通~
有批评大声说出来~因为我做得也不是很满意不过可以拿满分了就算了吧~
还有很多报告做~
#include<iostream.h>
#include<string>
#include<iomanip.h>
void main()
{
float mark1, mark2, mark3, mark4, mark5, average; //variable use in program
char grade, name[100], option, id[100];
do
{
for(int i=0; i<100; i++)
{
cout<<"-";
}
cout<<setw(50)<<"Welcome To"<<endl;
cout<<setw(57)<<"Inti College Subang Jaya"<<endl;
cout<<setw(52)<<"Grading System"<<endl;
for(int a=0; a<100; a++)
{
cout<<"-";
}
cout<<"\n\n";
cout<<"NOTED: 1.User be advise to set the console width to 100 width to have the best look."<<endl;
cout<<" 2.Input for student is advise enter atleast 7 chracter.\n"<<endl;
cout<<"\n";
cout<<"Please enter the name of the student\n:"; //show statement to request name of user
if(option=='y'||option=='Y')
{
cin.ignore(1,'\n');
}
cin.getline (name,30);
cout<<""<<endl;
cout<<"Please enter the id of the student\n:";
cin.getline(id,20);
cout<<""<<endl;
cout<<"Please enter the first mark of the student\n:"; //show statement to request 1st mark from the user
cin>>mark1;
cout<<""<<endl;
while(mark1>100||mark1<0) //loop for marks over 100 and smaller than 0
{
cout<<"Please make sure your first mark is an integer and is between 0 and 100, enter again\n:";
cin>>mark1;
cout<<""<<endl;
cout<<""<<endl;
//statement error reporting for wrong input marks1
}
cout<<"Please enter the second mark of the student\n:"; //show statement to request 2nd mark from the usewr
cin>>mark2;
cout<<""<<endl;
while(mark2>100||mark2<0)
{
cout<<"Please make sure your second mark is an integer and it is between 0 and 100, enter again\n:";
cin>>mark2;
cout<<""<<endl;
cout<<""<<endl;
//statement error reporting for wrong input marks2
}
cout<<"Please enter the third mark of the student\n:";
cin>>mark3;
cout<<""<<endl;
while(mark3>100||mark3<0)
{
cout<<"Please make sure your third mark is an integer and is between 0 and 100, enter again\n:";
cin>>mark3;
cout<<""<<endl;
cout<<""<<endl;
//statement error reporting for wrong input marks3
}
cout<<"Please enter the fourth mark of the student\n:";
cin>>mark4;
cout<<""<<endl;
while(mark4>100||mark4<0)
{
cout<<"Please make sure your fourth mark is an integer and is between 0 and 100, enter again\n:";
cin>>mark4;
cout<<""<<endl;
cout<<""<<endl;
//statement error reporting for wrong input marks4
}
cout<<"Please enter the fifth mark of the student\n:";
cin>>mark5;
cout<<""<<endl;
while(mark5>100||mark5<0)
{
cout<<"Please make sure your fifth mark is an integer and is between 0 and 100, enter again\n:";
cin>>mark5;
cout<<""<<endl;
cout<<""<<endl;
//statement error reporting for wrong input marks5
}
average=(mark1+mark2+mark3+mark4+mark5)/5;
for (int b=0; b<100; b++)
{
cout<<"-";
}
cout<<setw(55)<<"PRODUCING OUTPUT....."<<endl;
cout<<setw(53)<<"PLEASE WAIT......"<<endl;
for (int c=0; c<100; c++)
{
cout<<"-";
}
if(average>=70 && average<=100)
{
grade='A';
}
else if (average>=56 && average<=69)
{
grade='B';
}
else if (average>=40 && average<=55)
{
grade='C';
}
else
{
grade='D';
}
cout<<"\n\n\n\n";
cout<<"-------------------------------------------------------------------------------------------"<<endl;
cout<<"| Name | ID | Mark1 | Mark2 | Mark3 | Mark4 | Mark5 | Average | Grade|"<<endl;
cout<<"-------------------------------------------------------------------------------------------"<<endl;
cout<<" "<<name<<"\t"<<id<<" "<<mark1<<"\t "<<mark2<<"\t "<<mark3<<"\t "<<mark4<<"\t "<<mark5<<"\t "<<average<<"\t "<<grade<<endl;
for(int d=1; d<92 ;d++)
{
cout<<"-";
}
cout<<"\n\n"<<endl;
cout<<"You want to continue check another student's grade ? (Y/N)\n";
cin>>option;
}
while(option=='y'||option=='Y');
cout<<"\n\n\n"<<endl;
for(int e=0; e<100 ;e++)
{
cout<<"-";
}
cout<<setw(50)<<"THE END"<<endl;
for(int f=0; f<100 ;f++)
{
cout<<"-";
}
cout<<setw(56)<<"PROGRAM PREPARED BY"<<endl;
for(int g=0; g<100 ;g++)
{
cout<<"-";
}
cout<<setw(60)<<"Student Name: Tee Jing Yen (JY)"<<endl;
cout<<setw(42)<<"ID: J08003713"<<endl;
cout<<setw(41)<<"Course: DICT"<<endl;
cout<<setw(59)<<"Subject: Structured Progamming"<<endl;
for(int h=0; h<100 ;h++)
{
cout<<"-";
}
}
[ 本帖最后由 丧送狂曲 于 2009-2-25 08:20 PM 编辑 ] |
|