Article View: alt.comp.lang.learn.c-c++
Article #94Problematic Program
From: CM
Date: Sun, 20 Oct 2002 20:55
Date: Sun, 20 Oct 2002 20:55
94 lines
3597 bytes
3597 bytes
Hello everyone,
I thought I had finished a c++ V2 program when I ended up having several
unexpected compilation errors that I am not sure how to fix. 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
elements (each student has 3 double grades)
double GPA[5]; // array of gpa's (doubles)
double points;
for (i=0;i=noOfStudents-1;i++)
{
points=0;
cout<<"Enter information for Student #"<<i+1<<":"<<endl;
cout<<"\tName: ";
cin.getline(names[i],20);
cout<<"\n\tID: ";
cin.getline(ID[i],5);
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];
}
}
--
CM
Technical Details
Message-ID:
<ESudnc40b4i4hS6gXTWcow@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!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp3.aus1.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114592,635d58b7486c58ea,start X-Google-Attributes: gid114592,public X-Google-Thread: 109fba,635d58b7486c58ea,start X-Google-Attributes: gid109fba,public X-Google-Thread: 10d4ba,635d58b7486c58ea,start X-Google-Attributes: gid10d4ba,public X-Google-ArrivalTime: 2002-10-20 13:55:04 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!border1.nntp.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 15:55:01 -0500 From: "CM" <mckenzie992@comcast.net> Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++ Subject: Problematic Program Date: Sun, 20 Oct 2002 16:55:02 -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: <ESudnc40b4i4hS6gXTWcow@comcast.com> Lines: 96 X-Trace: sv3-20mdyvMZLhB2cB+SnCZ/qUOxg/940N1YXjGisA8jA5sXwBTxbX4+5ZliMqNe+vXbI6DOEYVMbPN3KgY!82pnRcmSVbwQapcGQfC0Rtj7Goe7z3Z5VmVKlqqVjk2XVV5RTTPk2PnsaZ8= 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