Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
studying the basics on the program...need some help!
Author Message
air_force91

Posted: Sat Nov 15, 2003 7:30 pm   Post subject: studying the basics on the program...need some help!

alright here's the thing...i have this question to answer and i don't need any answers...but could u edit my codes??? there seems to be something wrong with the formula of the "staverage" and how do i get the average in one decimal place????

%declare variables
var name,course1,course2,course3 : string
var mark1,mark2,mark3,average,staverage : real

%capture name, three courses and marks
get name
put "Hello, ",name,"! Enter a course you are taking"..
get course1
put "Great! Enter another course you are taking"..
get course2
put "Wow! Enter another course you are taking"..
get course3

%calculate student average
staverage:=(course1+course2+course3)/3

krishon

Posted: Sat Nov 15, 2003 8:19 pm   Post subject: (No subject)

this should be moved to help...but newayz

course1, 2 and 3 are strings, so u can't divide them...try using mark 1,2 and 3 instead...u have more variables than necesary, but that's ok, its just beter to use fewer
Tony

Posted: Sat Nov 15, 2003 10:00 pm   Post subject: (No subject)

as for output to # of decimal place, use
 code: put 123.456:0:1

:0 does nothing, but if its another number, it would add spaces to the output to make word that length. Used for spacing of output.

:1 is the number of decimal places to display
Tony's programming blog. DWITE - a programming contest.
air_force91

Posted: Sat Nov 15, 2003 10:52 pm   Post subject: (No subject)

but the code doesn't the work...the won uve sent...i get 9 decimal places for my answer instead of one...
air_force91

Posted: Sat Nov 15, 2003 10:57 pm   Post subject: (No subject)

sorry...nevermind...i got it...i just had to put "put staverage:0:1" instead of the decimal number u gave me...thanx for ur help!!!!!! another question...if u have time...i have to answer a question that says "write at least 2 questions. Each question on its own screen."

do u think that i would need to use the "randomize" command for this?
Tony

Posted: Sat Nov 15, 2003 11:06 pm   Post subject: (No subject)

no, i dont think you have to use Rand to write two questions on separate screens. You might have to use cls instead
Tony's programming blog. DWITE - a programming contest.
Thuged_Out_G

Posted: Sun Nov 16, 2003 1:32 am   Post subject: (No subject)

here, try this for your program...change the put statements to whatever you want them as.