Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 6895|回复: 45
打印 上一主题 下一主题

c++ 中级/中下级程式(计算学生分数grade)

[复制链接]

26

主题

1

好友

2082

积分

白金长老

Rank: 10

跳转到指定楼层
1#
发表于 2009-2-25 08:01 PM |只看该作者 |倒序浏览
这个是我的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 编辑 ]




收藏收藏0

0

主题

9

好友

69

积分

中级会员

Rank: 2Rank: 2

2#
发表于 2009-2-27 12:16 AM |只看该作者
基本上跟我看到的沒有太大出入
我所看過的cin跟你的有點不同
遲點再研究研究

你公佈你的自己的資料((背後幾行
沒有問題嗎em0026


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

3#
发表于 2009-2-27 07:11 AM |只看该作者
那不是我的ic或什么~不会怎样的...那是附加资料...好让我lecturer方便~要考虑到user的~
我的cin是设来接受输入空格的~普通cin会混乱


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

4#
发表于 2009-2-28 07:59 PM |只看该作者
你的assignment几分啊?
满容易的。
我们的看了都头大,超过一半以上的人不会做。
烦恼


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

5#
发表于 2009-3-1 03:24 AM |只看该作者
老实说当我们看到这个题目都笑死了~因为看了题目怒就想到了全部的code了~我们coursework占60分~他是其中一个~10分而已


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

6#
发表于 2009-3-1 12:57 PM |只看该作者
原帖由 丧送狂曲 于 2009-3-1 03:24 AM 发表
老实说当我们看到这个题目都笑死了~因为看了题目怒就想到了全部的code了~我们coursework占60分~他是其中一个~10分而已

那么容易拿十分啊?
早知道去你那里读了,我们的十分要几个礼拜才能做好。
而且每几个人会


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

7#
发表于 2009-3-1 01:25 PM |只看该作者

回复 #6 Cougar 的帖子

我们只是diploma阿~不会太难的~只是入门~
读不是为了容易毕业啊是要学习啊


回复

使用道具 举报

33

主题

3

好友

3236

积分

本站名嘴

Rank: 11Rank: 11

8#
发表于 2009-3-1 02:27 PM |只看该作者
我对C瞒有兴趣的!教教我吧!你这个C++的code跟C有什么分别?


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

9#
发表于 2009-3-1 03:28 PM |只看该作者

回复 #8 early_bird 的帖子

其实没什么分别....全部都没有分别的只是code而已
还有要学请自己开始再来问

[ 本帖最后由 丧送狂曲 于 2009-3-1 03:29 PM 编辑 ]


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9Rank: 9

10#
发表于 2009-3-1 05:01 PM |只看该作者

回复 #7 丧送狂曲 的帖子

Assignment 给的也要点逻辑啊,没教那么多,但要我们做多多。
要我们自己去研究找资料,那他存在有什么意义呢?
毕业了,我应该不会找IT的工作。


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-6-29 01:10 PM , Processed in 0.102346 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部