This message was edited by tlmcduffie at 2003-9-20 12:33:22
: I need some help getting my program(QBasic) to work right for me. My project is to simply write a program that inputs name, age, and 5 test scores. If the person's age is not 25 or older, then a message should say that the student is underage. I need the program to calculate the 5 scores and give me the average, and then tell me the different letter grades A,B,C,D, and if the average is below a 70%, then i need for a message to say that the student did not pass. I am stuck, someone with more knowledge please help, i would be most appreciative.....
:
Try copy/pasting this program and running it.
It will start by asking for 4 parameters. These are:
A grade (1-100) you consider to be the lowest A,B,C and D. Based on this, it gives the grades A thru F to the tests and the average. An average below 70% can be failing (like you asked) but you would have to tell it that the lowest "D" would be 70. This should give you some flexibility. Hope this helps, and GOOD LUCK!!
dim grade(5), lowGrade(4), testName$(5), seq$(5)
seq$(1)="first "
seq$(2)="second"
seq$(3)="third "
seq$(4)="fourth"
seq$(5)="fifth "
grLetter$="ABCD"
begin:
color 7,0
cls
print "Test averaging program"
print "======================"
print
print "Lets enter some basic info before we get started .."
print
for ix%=1 to 4
print "enter a number (1-100) that you consider to be the lowest ";mid$(grLetter$,ix%,1);
input lowGrade(ix%)
print string$(78,"-")
next ix%
enterTests:
color 7,0
cls
line input "Enter student name or / to end program: ";name$
if name$="/" then
cls
end
end if
line input "Enter student age : ";age$
age%=val(age$)
print string$(78,"=")
for ix%=1 to 5
print "Enter the subject name for the ";seq$(ix%);" test: ";
line input testName$(ix%)
line input "Enter the grade for this test (1-100): ";grade$
grade(ix%)=val(grade$)
print string$(78,"-")
next ix%
cls
displayReport:
color 7,0
cls
gosub computeAverage
print "Test Average Report for ";name$
print
print "Age is ";age$
if (age%=>25)=0 then
color 6,0
print " ** Student is underage **"
end if
color 7,0
stuGrade=average
gosub determineAthruF
print "Test average is";
print using "###.##";average
print "This is a grade of ";grade$
if grade$="F" then
color 4,0
print "** Student did not pass **"
end if
color 7,0
print
print "Test Summary (those in ";
color 4,0
print "red";
color 7,0
print " are failing)"
print
for ix%=1 to 5
color 7,0
stuGrade=grade(ix%)
gosub determineAthruF
rptName$=space$(25)
mid$(rptName$,1)=testName$(ix%)
if grade$="F" then
color 4,0
end if
print rptName$,grade$,
print using "###.##";stuGrade
next ix%
color 7,0
print
line input "Do you wish to average another student (Y/N) ";yn$
yn$=ucase$(yn$)
if yn$="Y" then
goto enterTests
end if
end
computeAverage:
total=0
for ix%=1 to 5
total=total+grade(ix%)
next ix%
average=total/5
return
determineAthruF:
if stuGrade=>lowGrade(4) then
grade$="D"
if stuGrade=>lowGrade(3) then
grade$="C"
if stugrade=>lowGrade(2) then
grade$="B"
if stuGrade=>lowGrade(1) then
grade$="A"
end if
end if
end if
else
grade$="F"
end if
return