w c++ 中级/中下级程式(计算学生分数grade) - 电脑语言编程讨论区 JBTALKS.CC -->
Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 7813|回复: 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

2

主题

0

好友

1633

积分

白银长老

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

46#
发表于 2009-3-19 07:36 PM |只看该作者
我malacca的~


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

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

45#
发表于 2009-3-19 07:17 PM |只看该作者
原帖由 Krazierrebel 于 2009-3-18 03:28 PM 发表
我上个short sem拿data structure & algorithm
没有assignment
Fikri人真好~

MMU 吗?
malacca 还是 cyber?
Assignment 很多人不会做,cyber 和 malacca 的assignment 不同。
cyber 的很难。
那个 Goh XX,有病的。
以为每个人很厉害。。。


回复

使用道具 举报

2

主题

0

好友

1633

积分

白银长老

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

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

回复 #43 Cougar 的帖子

我上个short sem拿data structure & algorithm
没有assignment
Fikri人真好~


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

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

43#
发表于 2009-3-7 05:25 PM |只看该作者
原帖由 Super-Tomato 于 2009-3-7 12:28 PM 发表



我覺得你該拿起你的課本認真的看看所學的, 沒學過的可以看看目錄翻到指定頁面閱讀和實習
不然的話我覺得你現在該轉換科系還來得急, 不要浪費自己未來的時間和金錢

我尽量找找看,能过关就好了


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

42#
发表于 2009-3-7 12:28 PM |只看该作者
原帖由 Cougar 于 2009-3-7 12:02 PM 发表

什么语言啊?
INSERT了过后,然后怎样把它正确的display出来?
我的program在前面之能够store character by character。
我display的时候就之能够character by character。
要怎样store string(一个word)呢?
还有就是,去完全不知道要怎样detect INSERT INTO的keyword....



我覺得你該拿起你的課本認真的看看所學的, 沒學過的可以看看目錄翻到指定頁面閱讀和實習
不然的話我覺得你現在該轉換科系還來得急, 不要浪費自己未來的時間和金錢


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

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

41#
发表于 2009-3-7 12:02 PM |只看该作者
原帖由 Super-Tomato 于 2009-3-6 10:44 PM 发表



执行 console 必须打开 bat 档

什么语言啊?
INSERT了过后,然后怎样把它正确的display出来?
我的program在前面之能够store character by character。
我display的时候就之能够character by character。
要怎样store string(一个word)呢?
还有就是,去完全不知道要怎样detect INSERT INTO的keyword.
给点头绪好吗?拜托em0068


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

40#
发表于 2009-3-6 10:44 PM |只看该作者
原帖由 Cougar 于 2009-3-6 08:05 PM 发表

可能是first sem 的时候听不懂,然后开始反感。
现在很怕写Program,看到code都会怕。
你那个file是用什么开的,IBM DB2?
.exe 很快就没有了,看不到东西。



执行 console 必须打开 bat 档


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

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

39#
发表于 2009-3-6 08:08 PM |只看该作者
原帖由 丧送狂曲 于 2009-3-6 08:19 AM 发表
setting up network 也要知道progamming的~
骇客也是network的高手的.....
不可能只会physical setting 然后不具备internal吧

是吗?
以前看我做工的地方,IT部门好像只是install hardware,setup hardware。
把坏的电脑换掉,maintain server,好像不会难的。
就是看到这样,所以觉得很想不难


回复

使用道具 举报

11

主题

0

好友

1584

积分

白银长老

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

38#
发表于 2009-3-6 08:05 PM |只看该作者
原帖由 Super-Tomato 于 2009-3-6 08:00 AM 发表



因为在學習过程你没把心投入,自然也不會花時間在 coding 上
所以就无法举一反三



你先做到這個步驟,之後再做UPDATE, DELETE, SELECT 等

可能是first sem 的时候听不懂,然后开始反感。
现在很怕写Program,看到code都会怕。
你那个file是用什么开的,IBM DB2?
.exe 很快就没有了,看不到东西。


回复

使用道具 举报

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

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

GMT+8, 2025-10-8 12:00 PM , Processed in 0.126419 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.
回顶部