Author Message

Hi, my problem is the construction of the following program.

There are 3 courses.(af1110, sp2200, en1010). Max # of students
that can take af1110  is 3 and 2 for the other courses.
The program asks for selecting a course(this is done 5 times)

for k=1 to 5
input"Give Course:";course\$
next k

When af1110 is selected then instead of 3 places that af1110 can hold,
now
should hold one less. So every time a course is selected, its available
places should
be reduced by 1. When there are no places in a course then the program
should
tell: Select another course.

THANKS !!!

Sun, 19 Nov 2000 03:00:00 GMT

Quote:

> Hi, my problem is the construction of the following program.

> There are 3 courses.(af1110, sp2200, en1010). Max # of students
> that can take af1110  is 3 and 2 for the other courses.
> The program asks for selecting a course(this is done 5 times)

> for k=1 to 5
> input"Give Course:";course\$
> next k

> When af1110 is selected then instead of 3 places that af1110 can hold,
> now
> should hold one less. So every time a course is selected, its available
> places should
> be reduced by 1. When there are no places in a course then the program
> should
> tell: Select another course.

> THANKS !!!

The reason you are given homework is so you will learn how to do it!

LB

Sun, 19 Nov 2000 03:00:00 GMT

Quote:
>Hi, my problem is the construction of the following program.

>There are 3 courses.(af1110, sp2200, en1010). Max # of students
>that can take af1110  is 3 and 2 for the other courses.
>The program asks for selecting a course(this is done 5 times)

>for k=1 to 5
>input"Give Course:";course\$
>next k

>When af1110 is selected then instead of 3 places that af1110 can hold,
>now
>should hold one less. So every time a course is selected, its available
>places should
>be reduced by 1. When there are no places in a course then the program
>should
>tell: Select another course.

>THANKS !!!

I'm not sure exactly what you need to do here however I'll give it my
best interpretation.

dim k(5) 'Not sure if it's really needed but good prog practice
for k=1 to 5
cls
?"(1)  AF1110";
if af1110=3 then
?" (CLOSED)"
else ?
end if
?"(2) SP2200";
if sp2200=2 then
?" (CLOSED)"
else ?
end if
?"(2) EN1010";
if en1010=2 then
?" (CLOSED)"
else ?
end if
do
spank=inkey\$()
loop until spank>0 and spank<4
if spank=1 then af1110=af1110+1
if spank=2 then sp2200=sp2200+1
if spank=3 then en1010=en1010+1
next k

It's crude but should do the job.

|_|_|_|/|
|_|_|_|/|
|_|_|_|/

Mon, 20 Nov 2000 03:00:00 GMT

Try to use collections!

if an index is removed the maximum will decrease and you can test this
behaviour.
Dim c as collections

Quote:
>Hi, my problem is the construction of the following program.

>There are 3 courses.(af1110, sp2200, en1010). Max # of students
>that can take af1110  is 3 and 2 for the other courses.
>The program asks for selecting a course(this is done 5 times)

>for k=1 to 5
>input"Give Course:";course\$
>next k

>When af1110 is selected then instead of 3 places that af1110 can hold,
>now
>should hold one less. So every time a course is selected, its available
>places should
>be reduced by 1. When there are no places in a course then the program
>should
>tell: Select another course.

>THANKS !!!

Mon, 20 Nov 2000 03:00:00 GMT

Quote:

> Hi, my problem is the construction of the following program.

> There are 3 courses.(af1110, sp2200, en1010). Max # of students
> that can take af1110  is 3 and 2 for the other courses.
> The program asks for selecting a course(this is done 5 times)

> for k=1 to 5
> input"Give Course:";course\$
> next k

> When af1110 is selected then instead of 3 places that af1110 can hold,
> now
> should hold one less. So every time a course is selected, its available
> places should
> be reduced by 1. When there are no places in a course then the program
> should
> tell: Select another course.

> THANKS !!!

DECLARE SUB CheckCourse (courseNo%)
af% = 3
sp% = 2
en% = 2

DO
CLS
PRINT "Enter 'A' for af1110, 'S' for sp2200, 'E' for en1010, 'Q' to
Quit"

INPUT "", c\$
SELECT CASE UCASE\$(c\$)
CASE "A"
CheckCourse af%
CASE "S"
CheckCourse sp%
CASE "E"
CheckCourse en%
CASE "Q"
EXIT DO
END SELECT
LOOP
CLS
END

SUB CheckCourse (courseNo%)

IF courseNo% <> 0 THEN
courseNo% = courseNo% - 1
ELSE
PRINT "Course Full, press any key..."
DO
LOOP UNTIL LEN(INKEY\$)
END IF

END SUB

Tue, 21 Nov 2000 03:00:00 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages