Posted: Wed Jan 09, 2008 4:04 pm Post subject: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
you have
var num : int
put "enter a number between 1 and 5"
get num
put "the number you entered is", num
when you copy and paste this, change it to
var num2 : int
put "enter a number between 1 and 5"
get num2
put "the number you entered is", num2
you need to different variable names. you can't declare two different variables with the same name. to add it together you can create a third variable that adds the two numbers or just use "put" to write what the two numbers add to
shakin cookie
Posted: Wed Jan 09, 2008 4:08 pm Post subject: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
Turing:
var num :int put"enter a number between 1 and 5" get num
put"the number you entered is", num
var num2 :int put"enter a number between 1 and 5" get num2
put"the number you entered is", num2
%then, to add the two numbers:
put" You're first number, ", num, ", + you're second number, ", num2, " is ", num + num2
%You could also just output the sum without any string statements:
% put num " + ",num2," = ",num+num2. "
that would be the coding for also outputting the answer.
iluvchairs112
Posted: Wed Jan 09, 2008 4:14 pm Post subject: Re: how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
or you could make a third variable
var sum : int
sum := num + num2
put sum[/list][/quote][/list]
Sponsor Sponsor
CodeMonkey2000
Posted: Wed Jan 09, 2008 4:43 pm Post subject: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
This is so unbelievably basic that it needs no explanation. Didn't your teacher go over this yet?
shakin cookie
Posted: Wed Jan 09, 2008 5:03 pm Post subject: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
yes, you could do that, but he needs the most basic answer.
Ya, i'm in grade 9, and my teacher went over this the third class, so his teacher must be doing it completely different.
Zampano
Posted: Wed Jan 09, 2008 5:30 pm Post subject: Re: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
shakin cookie @ Wed Jan 09, 2008 5:03 pm wrote:
yes, you could do that, but he needs the most basic answer.
Ya, i'm in grade 9, and my teacher went over this the third class, so his teacher must be doing it completely different.
Completely different? Is there anything one can do that doesn't in any way refer to such basic principles of programming but still teaches it?
I think some one has told you this before, but go over the basic things in the Turing Walkthrough and problems like these will become incredibly simple to you. Furthermore, if you run into problems, try and work something out on your self. If you tinkered with the code, you could easily have completed this on your own.
cwlvc
Posted: Wed Jan 09, 2008 5:50 pm Post subject: Re: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
shakin cookie @ Wed Jan 09, 2008 5:03 pm wrote:
yes, you could do that, but he needs the most basic answer.
Ya, i'm in grade 9, and my teacher went over this the third class, so his teacher must be doing it completely different.
it's because this is not our main thing. we never really went over this. we just got a booklet, did the booklet in 3 days all by ourselfs, then we were doing something else.
it's a computer engineer class, so we build circuits, and made a joy stick.
but i'll have computer science next semester so i'll prabably learn all about this.
cwlvc
Posted: Wed Jan 09, 2008 5:53 pm Post subject: Re: how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
how do i add a space between "is" and the number?
cause right now, after i type in my number, it is saying "the number you entered is1"
and how do i add a blank line between my first and second.
right now, it's
"the number you entered is1
enter a number between 1 and 5"
i'm looking for some space between those 2
Tony
Posted: Wed Jan 09, 2008 5:55 pm Post subject: RE:how to ask for 2 numbers, then the computer adds the numbers and give out the sum.
for spaces, just add an extra space, so "the number you entered is "
to add an extra line, you can either output a blank like