找回密码
 注册
查看: 850|回复: 8

我的第999帖---献给和我一样的C++的初学者.

[复制链接]
发表于 2003-1-24 11:06:13 | 显示全部楼层 |阅读模式
是我的功课, 放上来作为你们练习的题目吧. 哪位如果有兴趣, 也请不要在网上公布代码(至少在2月12日之前请保密)

[code:1]
CS 2310 Spring 2003

Project #1: Using struct and class data type to write a simple student records report program

This project is an elaboration of Lab 1. However, it requires using of class data type to manage the student records, in addition to the requirement of using struct data type to represent a student record.

Use Visual C++ to write your program.

As records secretary for Cougar High School, you have been asked by the principal to prepare a report on the grades of some of the school's top athletes.  Specifically, you must print each of the athlete's average letter grades based on their scores from three academic courses.  Input will be taken from the file stufile.txt, which is organized as follows: Each athlete in the file has four lines of information recorded - name (at most 20 characters including the comma and white space), student ID (SS#), class rank (1=Freshman, 2=Sophomore, 3=Junior, 4=Senior), and the three scores.  Information for at most 15 athletes is stored in the file, but the first fine of the file contains an integer showing the exact number of athletes.

Use struct data type as data representation of a student record, as described in Lab 1. However, this time, add another field to hold the letter grade. Look at the sample speficifation file proj1_prototype.h for the suggested data type declarations.

Then, define a class to hold an array of student records and encapsulate some member functions which will be used to do the specified reporting as described in the following. Again, Look at the sample speficifation file proj1_prototype.h for the suggested data type declarations.

You can assume that all scores are integers from 0 to 100.  Output from this program should be sent to a file named gfile.txt .  Athletes’ names ID numbers, class, ranks, and, letter grades are to be printed twice, the first time in order by letter grade, with "A" students first, “B" students second, and so forth.  The second time they are to be printed in order by rank, with freshman students first, sophomore students second, and so forth.  Note that the column of student ID numbers should be aligned three spaces beyond the maximum name length, the column of class ranks should be aligned three spaces beyond the column of student IDs, and the column of grades should be aligned three spaces beyond the column of class ranks.

A sample implementation file of the class member functions and a main function is written in file proj1_prototype.cpp. In the main function, there is an outline of the suggested steps to do the reporting job.

Turn in a diskette containing the header (.h) file, source code (.cpp file), and the I/O files.

stuflie.txt sample

10
Kevin Zitt
399-86-4533
1
65 78 66
Perry Placrue
455-78-9055
2
78 44 69
Alicia Placrue
678-89-4567
3
85 90 77
Pyretha Noosbaum,
456-78-9045
4
98 90 91
Hypatia Noosbaum,
456- 65-8023
1
99 95 92
Otto Mattick
218-45-8923
2
87 78 90
Alexander Grack
317-56-4555
3
67 87 56

S.T. Royd
435-69-0675
4
45 67 50
Derland Walpole
566-90-4563
1
78 89 65
Jellona Crimp
234-78-6745
2
38 56 89

gfile.txt sample

NAME        STUDENT ID   RANK            GRADE
                         
Hypatia Noosbaum        456-65-8023      Freshman        A
Pyretha Noosbaum        456-78-9045      Senior        A

Alicia Aardvark        678-89-4567      Junior        B
Otto Mattick        218-45-8923      Sophomore        B

Alexander Grack        317-56-4555      Junior        C
Derland Walpole        566-90-4563      Freshman        C

Jellona Crimp        234-78-6745      Sophomore        D
Perry Plaque        455-78-9055      Sophomore        D
Kevin Zitt        399-86-4533      Freshman        D

S.T. Royd        435-89-0675      Senior        F



NAME        STUDENT ID   RANK            GRADE

Hypatia Noosbaum        456-65-8023      Freshman        A
Derland Walpole        566-90-4563      Freshman        C
Kevin Zitt        399-86-4533      Freshman        D

Jellona Crimp        234-78-6745      Sophomore        D
Otto Mattick        218-45-8923      Sophomore        B
Perry Plaque        455-78-9055      Sophomore        D

Alicia Aardvark        678-89-4567      Junior                     B
Alexander Grack        317-56-4555      Junior                     C

Pyretha Noosba        456-78-9045      Senior                     A
S.T. Royd        435-89-0675      Senior                     F
[/code:1]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

×
发表于 2003-1-24 12:09:13 | 显示全部楼层
!什么!!!e文恶!!!!大头
回复

使用道具 举报

发表于 2003-1-29 20:58:20 | 显示全部楼层
I can not see any point why this assignment need C++, especially VC++. C, Perl or even Java is sufficient to do this job in a much efficient manner. Perl may be the very choice from my view, since this task is simply a pure plain-text processing job. This sort of work can only appear in an introductory course of programming language. Man, a piece of cake won't entertain anybody. By the way, why VC? I can not see any advantage from VC in this case. None of GUI, WinAPI, or STL stuff is concened here. Or you school only provides such commercial compiler? Amazing. I thought western university all settle in Unix/Linux/BSD as primary working platform. Cos in Australia it is so, and many of my US friends expressed the same idea. I am not here blaming u or MS, but just feel interested in why an academic institution employs commcercial application when it is not that necessary.

Comments? I will be back later.
回复

使用道具 举报

 楼主| 发表于 2003-1-29 23:04:59 | 显示全部楼层
这个帖子只是提供一道练习题,不是在讨论编程语言的优缺点,更不是在讨论compiler。我们学校在NT上运行VS, 在Unix/Linux运行诸如GCC之类的compiler,这有什么奇怪的。都不知道你跟帖的目的何在。如果你连主题都看不懂,不知道这帖子的目的是什么,却在一旁夸夸其谈地炫耀自己,我只好再一次提醒你,看清楚别人的帖子再接话。如果你的理解能力实在是低下的话,或者你认为我为人恶劣的话,你大可不必跟我的帖子。
回复

使用道具 举报

 楼主| 发表于 2003-1-30 01:37:36 | 显示全部楼层
[quote:5ec005167c="damonbi"]I can not see any point why this assignment need C++, especially VC++. C, Perl or even Java is sufficient to do this job in a much efficient manner. [/quote]
哈哈。我也觉得好笑。人吃饭为什么要用筷子,汤匙,刀叉?用手抓不是更能活动更多的肌肉和锻炼大脑吗?
[quote:5ec005167c="damonbi"]Perl may be the very choice from my view, since this task is simply a pure plain-text processing job. This sort of work can only appear in an introductory course of programming language. Man, a piece of cake won't entertain anybody. [/quote]
你吃大餐吃惯了,当然对小蛋糕看不上。
[quote:5ec005167c="damonbi"]By the way, why VC? I can not see any advantage from VC in this case. None of GUI, WinAPI, or STL stuff is concened here. Or you school only provides such commercial compiler? Amazing. I thought western university all settle in Unix/Linux/BSD as primary working platform. Cos in Australia it is so, and many of my US friends expressed the same idea. I am not here blaming u or MS, but just feel interested in why an academic institution employs commcercial application when it is not that necessary.[/quote]原来仁兄在澳大利亚,澳大利亚的学校是否都是用Unix,我这倒不知道。但你那些所谓U.S. friends牛人 说的U.S University都是用Unix/Linux/BSD作为主要平台的话,我想那也是属于整天在实验室里难见天日的那类。
回复

使用道具 举报

发表于 2003-1-30 08:03:20 | 显示全部楼层
在美国的话,作科学计算,都是在*NIX系统下面的。CS两种系统都用,因为MS的东西毕竟是计算机,但是*NIX还是主导,很多学生都是用网路直接连接到学校主机上作作业。甚至办公室里面的计算机也不过都是充当SUPER大的服务器的一个终端,运行什么程序都在服务器上面。
不要和我吵架,我怕。我就是说说我知道的。
回复

使用道具 举报

 楼主| 发表于 2003-1-31 05:53:30 | 显示全部楼层
怎么也看不出来你怕在哪里。现在不是你不知道,而是变成我不知道了。我就不知道一道练习题,只是提供给大家练手的,标题也写明是给初学者的。你既然自认为是高手了,又精通那么多语言,却又要进来把话题引到操作系统上去。你爱用什么语言,爱用什么系统,觉得这题目简单还是难,和我这个帖子一点关系都没有。
回复

使用道具 举报

发表于 2003-1-31 14:47:14 | 显示全部楼层
HOUSCOUS, 少说两句,什么大不了的事,没完没了的阿     
回复

使用道具 举报

 楼主| 发表于 2003-1-31 23:30:56 | 显示全部楼层
说的是,就此对这个帖子停止发表意见。祝大家新年快乐,包括向我提出意见的朋友们...
回复

使用道具 举报

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

本版积分规则

GMT+8, 2025-2-25 19:06 , Processed in 0.038976 second(s), 16 queries .

© 2001-2025 Discuz! Team. Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表