Computer Science Canada

studying the basics on the program...need some help!

Author:  air_force91 [ 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
put "What is your name?"..
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

Author:  krishon [ Sat Nov 15, 2003 8:19 pm ]
Post 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

Author:  Tony [ Sat Nov 15, 2003 10:00 pm ]
Post 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

Author:  air_force91 [ Sat Nov 15, 2003 10:52 pm ]
Post subject: 

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

Author:  air_force91 [ Sat Nov 15, 2003 10:57 pm ]
Post 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?

Author:  Tony [ Sat Nov 15, 2003 11:06 pm ]
Post subject: 

no, i dont think you have to use Rand to write two questions on separate screens. You might have to use cls instead Laughing

Author:  Thuged_Out_G [ Sun Nov 16, 2003 1:32 am ]
Post subject: 

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

code:
var name,answer:string
var winID:int
var mark,mark1,mark2,staverage:real

winID:=Window.Open("position:top,center,graphics:640;640")

loop
put "Please enter your name: "..
get name
cls

put "Hello ", name, " Please enter marks for your first course: "..
get mark
cls

put "Please enter marks for your second course: "..
get mark1
cls

put "Please enter marks for your third course: "..
get mark2
cls

staverage:=(mark + mark1 + mark2)/3

put "Your average is: ", staverage
delay(10000)
cls

put "Would you like to continue(yes/no): "..
get answer
loop
if answer="no" then
Window.Close(winID)
end if
end loop
end loop


: