Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Calculator Prob

Author
Message
CaMeRoN H
19
Years of Service
User Offline
Joined: 21st Aug 2005
Location: Who knows?
Posted: 24th Aug 2005 05:03
Ok Heres the Code


Its all good but one prob. if i do addition it works but if i do subtraction for multiply etc. it just goes to add. y?

master programmer
19
Years of Service
User Offline
Joined: 30th May 2005
Location: 3D Space
Posted: 24th Aug 2005 05:39
First, I would change your "goto"'s to "gosub"'s. Your question I really don't understand...sorry

Tinkergirl
21
Years of Service
User Offline
Joined: 1st Jul 2003
Location: United Kingdom
Posted: 24th Aug 2005 05:46
Um, I'm not completely sure, but shouldn't you have quotes "" around your operands?

Eg.


Can you try that and see if it helps?
CaMeRoN H
19
Years of Service
User Offline
Joined: 21st Aug 2005
Location: Who knows?
Posted: 24th Aug 2005 06:00
Yes it worked

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 24th Aug 2005 06:14
Tinkergirl is onto the problem!

You have:

Input "Enter Operand, + Addition, - Subtraction, / Division, * Multiplication ", operand#

operand# is a float variable for storing real numbers - like 1.234 or 43.663.

You want to enter alphanumeric characters, so you need to be using a string for the input, (strings have a $ sign on the end of the variable name). So, it should be:

Input "Enter Operand, + Addition, - Subtraction, / Division, * Multiplication ", operand$

Then , Tinkergirl is correct - you should have quotes around the signs, as in:

if operand# = "+" then GOSUB add

masterprogrammer is also correct. Stop using Goto and use Gosub instead. Goto is the gateway to spaghetti code and your programs will be a nightmare to follow. Instead, use Gosub and use:

add:
print "The Sum Of ", num1#, " And ", num2#, " Is ", num1# + num2#
wait 3000
Return

Do the same to the other blocks too.

TDK_Man

CaMeRoN H
19
Years of Service
User Offline
Joined: 21st Aug 2005
Location: Who knows?
Posted: 24th Aug 2005 17:27
Oh i c now thanks all of you!

Login to post a reply

Server time is: 2024-11-27 18:50:19
Your offset time is: 2024-11-27 18:50:19