0 members and 2,045 guests
No Members online

» Site Navigation
» Stats
Members: 35,442
Threads: 103,075
Posts: 826,688
Top Poster: cc.RadillacVIII (7,429)
|
-
Is there anyway to make a case statement of an array? I am doing my CPSC assignment and having trouble with this mother.. I'm no coder hahaha
Well the program is supposed to prompt you to enter letter grades of a class of 25 students, it will convert ABCDF grades into GPA scores, and W will be a null value.... if the user decides to quit he/she can enter in 'Q' or 'q', and the loop will stop...
I have most of the program typed out, compiles and displays, but I'm moving on the next step.
So far my program will display ANY letter grade, so I decided to use a Case Statement.
I made the array type so I can pass into parameters of procedures:
type
gradeList = array(1..classMax)of char; **classMax is 5 students for now for testing**
and the array itself..
classGrades : gradeList
The input procedure is
procedure enterGrades (var classGrades : gradeList;
* * * * * * * * * * * var size* : integer);
begin
* var i* * * * * : integer;
* for i:=1 to classMax do
* begin
* * * writeln('Student #',(size+1),' Max students= ',classMax);
* * * write('Enter the letter grade for student #',i,': ' ;
* * * readln(classGrades[i]);
* * gradeInput(classGrades,size);
Now my problem is gradeInput procedure. It is the procedure of which it is checking if the values entered are valid. Also I need to find a way to get out of the loop without compromising the student counter in the FOR loop (size+1.
I tried doing this:
procedure gradeInput(var classGrades : gradeList;
* * * * * * * * * * * * * * * * * * var size* * * * * * :* integer);
begin
* var i : integer;* <-- in case I need it
* case(classGrades)* <--- I tried both classGrades and classGrades[i] 
* * 'A','a', etc. until 'F','f':* * <-- I didn't actually type etc and all that jazz
* * * size=size+1 (it is valid so the student counter goes up
etc.
It won't compile! probably because I don't know how to use case statements to read arrays 
Any help from coders is appreciated haha. Long read indeed.
-
Good luck finding help with pascal on here, not many people use that language nowadays. Try http://www.programmingtalk.com/ for your support questions, they've helped me with other various things in the past.
-
Thanks you so much ! :P
Similar Threads
-
By ThatTechPlace in forum Digital Art
Replies: 1
Last Post: 06-10-2006, 11:32 PM
-
By Ben in forum Other Tutorials
Replies: 7
Last Post: 04-11-2006, 08:55 PM
-
Replies: 7
Last Post: 01-14-2006, 05:33 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|