🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #96

Re: Problematic Program

#96
From: CM
Date: Sun, 20 Oct 2002 21:24
155 lines
5271 bytes

--
CM
"Neil Butterworth" <neil_butterworth@lineone.net> wrote in message
news:3db31a56$1_1@mk-nntp-1.news.uk.worldonline.com...
>
> "CM" <mckenzie992@comcast.net> wrote in message
> news:ESudnc40b4i4hS6gXTWcow@comcast.com...
> > Hello everyone,
> > I thought I had finished a c++ V2
>
> What does "V2" mean?
>
> > program when I ended up having several
> > unexpected compilation errors that I am not sure how to fix.
>
> All compilation errors are unexpected.
>
> The jist of
> > the program is to take 5 student names, 5 ids for those students, 3
grades
> > for each student and then calculate gpa displaying in a table format:
> > Name    Name 1     Name 2
> > Id            999            222
> > Grade 1     90        80
> > Grade 2     90        80
> > Grade 3
> > GPA
> > etc.
> >
> > I have included what I have so far, was hoping someone could help to
find
> my
> > mistake.
> > #include <string>
> > #include <iostream>
> > using namespace std;
> > #include <stdlib.h>
> > void main()
> > {
> > int noOfGrades=3;
> > int noOfStudents=5;
> > char names[noOfStudents]; // array of names (strings)
> > char ID[noOfStudents]; // array of ID's (strings)
> > double Grades[noOfStudents][noOfGrades]; // array of 5 arrays each of 3
>
> Your basic problem is here - the dimensions of automatic arrays in C++
must
> be constants known at compile time. One way of fixing your code would be
to
> declare your dimension sizes as:
>
> const int noOfGrades=3;
> const int noOfStudents=5;
>
> This will fix some, but not all. problems in your code. Patch these fixes
> in, try to fix the remaining problems and if you can't post here again.
But
> remember, we don't do homework for you.
>
> NeilB
>
>
>
>
>

Neil,
Thanks for the help.  I believe I have corrected all the errors however a
huge mess at run-time.  again, not sure what direction to take, if you could
be so kind as to give your feedback (or anyone else for that matter)

Thanks again (code below)

#include <string>
#include <iostream>
using namespace std;
#include <stdlib.h>
void main()
{
const int noOfGrades=3;
const int noOfStudents=5;
char names[noOfStudents]; // array of names (strings)
char ID[noOfStudents]; // array of ID's (strings)
double Grades[noOfStudents][noOfGrades]; // array of 5 arrays each of 3
elements (each student has 3 double grades)
double GPA[5]; // array of gpa's (doubles)
float points;
int j;
int i;
for (i=0;i=noOfStudents-1;i++)
{
points=0;
cout<<"Enter information for Student #"<<i+1<<":"<<endl;
cout<<"\tName: ";
//cin.getline(names[20],[i]);
cin>>names[i];
cout<<"\n\tID: ";
//cin.getline(ID[i],5);
cin>>ID[i];
for (j=0;j=noOfGrades-1;j++)
{
cout<<"\t\nGrade #"<<j+1<<": ";
cin>>Grades[i][j];
if (Grades[i][j] >= 0  && Grades[i][j] <= 59)
points+=0;
if (Grades[i][j] >= 60 && Grades[i][j] <= 64)
points+=1.0;
if (Grades[i][j] >= 65 && Grades[i][j] <= 69)
points+=1.5;
if (Grades[i][j] >= 70 && Grades[i][j] <= 74)
points+=2.0;
if (Grades[i][j] >= 75 && Grades[i][j] <= 79)
points+=2.5;
if (Grades[i][j] >= 80 && Grades[i][j] <= 84)
points+=3.0;
if (Grades[i][j] >= 85 && Grades[i][j] <= 89)
points+=3.5;
else
points+=4.0;
}
GPA[i]=points/noOfGrades;
j=0;

}

cout<<"\nName\t";
for (i=0;i=noOfStudents-1;i++)
{
cout<<"\t"<<names[i];
}

cout<<"\nID\t";
for (i=0;i=noOfStudents-1;i++)
{
cout<<"\t"<<ID[i];
}

for (j=0;j=noOfGrades-1;j++)
{
cout<<"\nGrade #"<<j+1<<"\t";
for (i=0;i=noOfStudents-1;i++)
{
cout<<"\t"<<Grades[i][j];
}
}

cout<<"\nGPA\t";
for (i=0;i=noOfStudents-1;i++)
{
cout<<"\t"<<GPA[i];
}

}
Technical Details
Message-ID: <HIacndmZkvBvgy6gXTWcoA@comcast.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed1.easynews.com!easynews.com!easynews!nntp2.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
References: <ESudnc40b4i4hS6gXTWcow@comcast.com> <3db31a56$1_1@mk-nntp-1.news.uk.worldonline.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 114592,635d58b7486c58ea
X-Google-Attributes: gid114592,public
X-Google-Thread: 109fba,635d58b7486c58ea
X-Google-Attributes: gid109fba,public
X-Google-Thread: 10d4ba,635d58b7486c58ea
X-Google-Attributes: gid10d4ba,public
X-Google-ArrivalTime: 2002-10-20 14:24:03 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed-east.nntpserver.com!nntpserver.com!newsfeed1.easynews.com!easynews.com!easynews!nntp2.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail
NNTP-Posting-Date: Sun, 20 Oct 2002 16:24:02 -0500
From: "CM" <mckenzie992@comcast.net>
Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++
References: <ESudnc40b4i4hS6gXTWcow@comcast.com> <3db31a56$1_1@mk-nntp-1.news.uk.worldonline.com>
Subject: Re: Problematic Program
Date: Sun, 20 Oct 2002 17:24:03 -0400
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <HIacndmZkvBvgy6gXTWcoA@comcast.com>
Lines: 157
X-Trace: sv3-q9pE60Qv/xOMt63DaC4Bz9ewm5dGupJAnvN1AaD3eQRmVpUPu2w+zTvG1TO+DCKvA2VhvEEh1iyIOlf!Ep+oVAND4rgl2HwdxnqvbynZzFKPL1wwNx6A/o06Z0nUMm4ysJ54eZfdGDE=
X-Complaints-To: abuse@comcast.com
X-DMCA-Complaints-To: dmca@comcast.net
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.1