Qbasicnews.com
July 11, 2020, 04:48:01 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] 2 3
  Print  
Author Topic: Need help please!!!!  (Read 8411 times)
hakeem
New Member

Posts: 3


« on: August 19, 2004, 05:51:06 AM »

I have to write a program where say if  I input 1 then it prints sunday, and if I input 2 then it prints monday and so on....

any help would be apreciated... :wink:
Logged
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #1 on: August 19, 2004, 05:58:44 AM »

Have you tried yet? If so, lets see some code. We wont just do your homework for you Wink
Logged
citpes
Guru
**
Posts: 254


« Reply #2 on: August 19, 2004, 05:59:01 AM »

HAHAHAHAHAHAHA :rotfl:  :rotfl:  :rotfl:

just give me a min to compose myself again...
..
..

ok, sorry bout that.

hakeen you read the rules?  This is obviously a homework assingment.  Try listen in class and it would be easy.  You might get lucky and have a bored member here write this but it aint gonna be me.

heres a tip though, look up INPUT and IF THEN ELSE.  there are a span of tuts on the net (even on this very site (WOW :roll: )!)

EDIT: 1 min, damn you dark!
Logged
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #3 on: August 19, 2004, 06:56:38 AM »

Quote from: "citpes"
EDIT: 1 min, damn you dark!

Heh Grin

But actually, I dont think he was trying to cover the fact that its a homework assignment.
Logged
citpes
Guru
**
Posts: 254


« Reply #4 on: August 19, 2004, 07:14:02 AM »

would it even be possible to cover that up?

But, yea, hakeem, just look up those commands i gave you in my first post.  Qb's help is actually quite good, just type in the word and hit F1 when the cursor is on it.  maybe you can get the basic idea, then post what you have and you will find that the ppl here are actually really nice.
Logged
hakeem
New Member

Posts: 3


« Reply #5 on: August 19, 2004, 10:54:37 AM »

Allright boys..
have a laugh,
you got me there :lol:
the honest fact is that not all of us here are blessed with computer.
Well anyways i got a bloke here helping me out with it, :wink:  
thanks for tips anyways
Hakeem Cool
Logged
HQSneaker
Wandering Guru
***
Posts: 394



WWW
« Reply #6 on: August 19, 2004, 11:11:07 AM »

You should use SELECT CASE for this one, much better than IF
Logged
Z!re
*/-\*
*****
Posts: 4599


« Reply #7 on: August 19, 2004, 08:54:40 PM »

*sigh*

No, SELECT CASE is easier to read, FOR SOME people.

IF is faster.


I posted a thread about it some time ago, called optimization or something...
Logged
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #8 on: August 19, 2004, 09:34:12 PM »

Allright boys? Are you assuming that only boys can program? ahh

anyways. I got bored and made a  program like this. and guess what! it doesn't use IF or SELECT! mwahaha
[syntax="QBASIC"]CLS
days$ = "Sunday   Monday   Tueday   WednesdayThursday Friday   Saturday "
lod = 9
INPUT "Gimme a number! ", num
num = ((num < 1) * -1) + num
PRINT RTRIM$(MID$(days$, lod * (num - 1) + 1, lod))[/syntax]

EDIT: actualyl I made a program that you input your name and it writes it to a file and says "welcome back" and stuff. but I trimmed it down =D

EDIT2: you can now enter a number less then 1 and it makes it 1.
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
KiZ
__/--\__
*****
Posts: 2879


WWW
« Reply #9 on: August 20, 2004, 05:00:41 AM »

Quote from: "Z!re"
*sigh*

No, SELECT CASE is easier to read, FOR SOME people.

IF is faster.


I posted a thread about it some time ago, called optimization or something...


psst... Z!re... I dont think that 1/10000s of a second faster speed is going to matter to a guy who is new to programming and only doing it because its school work. Grin

Quote
guess what! it doesn't use IF or SELECT! mwahaha

O_o    ooooh. Ingenious
Logged
ak00ma
Ancient Guru
****
Posts: 669



« Reply #10 on: August 20, 2004, 06:12:42 AM »

Quote from: "whitetiger0990"
Allright boys? Are you assuming that only boys can program? ahh

anyways. I got bored and made a  program like this. and guess what! it doesn't use IF or SELECT! mwahaha
[syntax="QBASIC"]CLS
days$ = "Sunday   Monday   Tueday   WednesdayThursday Friday   Saturday "
lod = 9
INPUT "Gimme a number! ", num
num = ((num < 1) * -1) + num
PRINT RTRIM$(MID$(days$, lod * (num - 1) + 1, lod))[/syntax]

EDIT: actualyl I made a program that you input your name and it writes it to a file and says "welcome back" and stuff. but I trimmed it down =D

EDIT2: you can now enter a number less then 1 and it makes it 1.


Not bad Wink
But didn't you think of arrays?
Code:

DIM Days$(7)
Days$(0) = "Sunday"
Days$(1) = "Monday"
Days$(2) = "Tuesday"
Days$(3) = "Wednesday"
Days$(4) = "Thursday"
Days$(5) = "Friday"
Days$(6) = "Saturday"
INPUT "Please enter a number (between 0 and 6)", n
n = n MOD 8 'If there's someone who doesn't know how to read!!
PRINT STR$(n) + "-->" + Days$(n)
Logged

B 4 EVER
Z!re
*/-\*
*****
Posts: 4599


« Reply #11 on: August 20, 2004, 08:21:42 AM »

I thought of arrays, but didn't post, as this is a school assigment...

doh...
Logged
whitetiger0990
__/--\__
*****
Posts: 2964



WWW
« Reply #12 on: August 20, 2004, 01:37:32 PM »

Yeah I thought of arrays. But Mine takes up less room =P
I don't know if it's faster though =\
Logged


[size=10]Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.[/size]
Z!re
*/-\*
*****
Posts: 4599


« Reply #13 on: August 20, 2004, 01:41:08 PM »

prolly not, but i dunno...

Dosent matter much, lol =)

The fastest would prolly be:

Code:
if day = 1 then print "monday": end
if day = 2 then print "tuesday": end
if day = 3 then print "wednesday": end
if day = 4 then print "thursday": end
if day = 5 then print "friday": end
if day = 6 then print "saturday": end
if day = 7 then print "sunday": end
Logged
ak00ma
Ancient Guru
****
Posts: 669



« Reply #14 on: August 20, 2004, 05:38:44 PM »

Code:

DIM D$(7)
D$(0) = "Sunday":D$(1) = "Monday":D$(2) = "Tuesday":D$(3) = "Wednesday":D$(4) = "Thursday"
D$(5) = "Friday":D$(6) = "Saturday"
INPUT "Please enter a number (between 0 and 6)", n
PRINT STR$(n MOD 8) + "-->" + D$(n MOD 8)

Wink
Logged

B 4 EVER
Pages: [1] 2 3
  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!