Qbasicnews.com
November 19, 2019, 02:15:05 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: help me please ( students digree programe )  (Read 2510 times)
mon4live
New Member

Posts: 3


« on: December 15, 2006, 06:36:36 PM »

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 >......
Logged
Ralph
Ancient Guru
****
Posts: 544


« Reply #1 on: December 15, 2006, 10:41:25 PM »

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.
Logged

Ralph, using QuickBASIC 4.5 and Windows XP Home Edition and Service Pack 2, with HP LaserJet 4L printer.
mon4live
New Member

Posts: 3


« Reply #2 on: December 16, 2006, 09:35:41 AM »

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
Logged
red_Marvin
Na_th_an
*****
Posts: 1509



WWW
« Reply #3 on: December 16, 2006, 12:38:13 PM »

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
Logged

/post]
mon4live
New Member

Posts: 3


« Reply #4 on: December 16, 2006, 01:44:51 PM »

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:
Logged
red_Marvin
Na_th_an
*****
Posts: 1509



WWW
« Reply #5 on: December 16, 2006, 04:53:44 PM »

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...
Logged

/post]
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!