Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
help me please ( students digree programe )
#1
hello every body
please help me to do this operation in qbasic

i want to make a programe calculating students digree
i means when u run the programe
it askes u to enter your mark in x%
and if your mark bitween 0:20 it's type
your degree is : bad
and if bitween 21:40 it's print not bad
and if 41:60 print good
and if 61:80 print very good
and if 81:100 print exiellent

forgive me for my bad english writing because i'm from egypt
and thanks for help .....
i'm waiting >......
Reply
#2
Your program seems quite doable. But, please post here what you have written for your program (I assume you have started to write the program, but are having problems). We will be more than happy to help you solve the various problems that you may encounter in writing your program, but, we really shouldn't do your program for you, totally.

So, post your program, as is, and ask questions relating to it.
Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
Reply
#3
my programe is a broblem

but i'll type to to u what i want to do ....

Quote:10 input "please enter your marks in x%",marks
if 0 < marks < 20 then
let digree = " bad "
if 21 < marks < 40 then
let digree = "not bad"
if 41 < marks < 60 then
let digree = "good"
if 61 < marks < 80
let digree = "very good"
if 81 < marks < 100 then
let digree = "exilleant"
end if
print "digree =";digree
goto 10

i hope u can help me ..... and thanks for your
Reply
#4
Writing
if a < stuff < b then
won't do what you expect (from a math point of view)
but you need to write
if a<stuff and stuff<b then
/post]
Reply
#5
Quote:Writing
if a < stuff < b then
won't do what you expect (from a math point of view)
but you need to write
if a<stuff and stuff<b then

i'm not understanding u ... but if u can write it in numbers

like example ... if ... < .... <.... then
......
only one and i'll continue writing the programe

and thanks for replay .... :wink:
Reply
#6
Look at the following code:
Code:
dim x as integer
input "Input a number: ", x
if 3 < x < 10 then
  print "x is between 3 and 10"
end if
It is somewhat similar to what you are trying to achieve and it looks like it will print the message "x is between 3 and 10" if it indeed is.
But it won't behave as expected.
IIRC Qbasic "if" statements work by examining each "question" at it's own
and if it's evaluates to true replace it with -1 but if it's false replace it with 0.
So say, if you input the number 7, it is between 3 and 10, but if won't work that way, instead it will do this:
examine first part:

if 3 < x < 10 then

3 is less than 7 so qbasic puts a -1 at it's place. Then we have

if -1 < 10 then

and -1 is of course less than true so it works here.

But what if we input a number that's smaller than 3 into x? Say x=1...

if 3 < x < 10 then

3 < 0 evaluates to false, so qbasic put's a 0 in it's place

if 0 < 10 then

0 < 10 evaluates to true so the message is printed even though x clearly isn't between 3 and 10

Finally we can try with a number that's bigger than 10, say 33:

if 3 < x < 10 then

3 < 10 evaluates to false, so qbasic put's a -1 in it's place

if -1 < 10 then

-1 < 10 evaluates to true so the message is printed even though x clearly isn't between 3 and 10

If you want it to work you have to write
Code:
dim x as integer
input "Input a number: ", x
if 3 < x and x < 10 then
  print "x is between 3 and 10"
end if

which is equal to
Code:
dim x as integer
input "Input a number: ", x
if (3 < x) and (x < 10) then
  print "x is between 3 and 10"
end if

Now it might be a little clearer just read it out : If 3 is smaller than x and x is smaller than 10...
/post]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)