
-----------------------------------
batgirl13
Sun Oct 05, 2008 5:10 pm

how do i make this simple program?
-----------------------------------
hi, 
i need a program that will :

a) Ask the user for an integer at which to start and stop. (***as in, start at 5 stop at 14....then add all the numbers in between, ect.***) Print the sum and average between the start and stop integers.  

b) Print the sum and average (including the start and stop values).  Use a ?loop? command.

c) Same as above but using If ? Then and counter(s).



im lost :c
any help would be much appreciated

-----------------------------------
Insectoid
Sun Oct 05, 2008 5:14 pm

RE:how do i make this simple program?
-----------------------------------
How bout try to make the program ,THEN ask for help. Wouldn't that be fun?

-----------------------------------
batgirl13
Sun Oct 05, 2008 8:36 pm

Re: how do i make this simple program?
-----------------------------------
var int1: int
var int2: int
var counter: int

loop
put "Please enter an integer to start."
get int1
counter:= counter+1
delay(500)
put "Please enter an integer to stop."
get int2
counter:= counter+1
delay(500)
cls
var int12: array int1 .. int2 of int
put "The sum of your numbers is ", int1 .. int2(i) , "."
delay(250)
put "The average of your numbers is ", int1 .. int(i)2/2, "."
delay(500)
cls
if int12>5 then 
put "There are more than 3 numbers between ", int1, "and ", int2, "."
elsif
put "You have entered ", counter, " numbers so far."
end if
delay(500)
cls
end loop




theres my program so far....i know it fails really badly...i tried :c
please help?

Mod Edit: Remember to use Syntax tags. [syntax="Turing"]Code[/syntax]

-----------------------------------
gitoxa
Sun Oct 05, 2008 9:31 pm

RE:how do i make this simple program?
-----------------------------------
You can't use "int1" and "int2" as variable names, they are already used as data types for Turing. An easy way to tell if you can use something as a variable name is that the writing will be blue in the Turing interface.  Also, try to make your variable names meaning, perhaps something like "FirstNum" and "LastNum"

I was going to critique your program step by step, but after looking past your variable names I realize your program is quite the headache :P

You need to think it through before writing any code out.  What exactly do you what to do, step by step.  It helps if you write this out (or type).

After that you can then tackle your program one step at a time.

-----------------------------------
Zren
Mon Oct 06, 2008 12:17 am

Re: how do i make this simple program?
-----------------------------------
Probably much easier with a for loop...

Long live Pseudo code

get the start and end varibles
for i : start .. end
sum+=i
end for
put the sum
put the sum divided by the difference between the start and end



...Waitaminute, what are you doing with that array? Are you trying to get a list of numbers that the user inputs to add together?

and what in ____ name is this? Or what does it do / is suppose to do?
put "The sum of your numbers is ", int1 .. int2(i) , "." 

-----------------------------------
S_Grimm
Tue Oct 07, 2008 10:21 am

RE:how do i make this simple program?
-----------------------------------
please stop using delays. the slow down the program and are useless UNLESS it is a game with animations...

-----------------------------------
andrew.
Tue Oct 07, 2008 8:33 pm

RE:how do i make this simple program?
-----------------------------------
Why did you use an array? Try simpler things first like a for loop and if those won't work, then use an array. In this case, a for loop would work great.

-----------------------------------
Shamusodoofus
Wed Oct 08, 2008 2:19 am

Re: RE:how do i make this simple program?
-----------------------------------
Why did you use an array? Try simpler things first like a for loop and if those won't work, then use an array. In this case, a for loop would work great.

A loop would work. But an array would be the best choice in this situation since you will use up less code than a loop since you want to add every number in between 2 numbers (eg. 2 and 5, so we add 2+3+4+5 = 14).

-----------------------------------
Warchamp7
Wed Oct 08, 2008 7:43 am

Re: RE:how do i make this simple program?
-----------------------------------
Why did you use an array? Try simpler things first like a for loop and if those won't work, then use an array. In this case, a for loop would work great.

A loop would work. But an array would be the best choice in this situation since you will use up less code than a loop since you want to add every number in between 2 numbers (eg. 2 and 5, so we add 2+3+4+5 = 14).

Actually, a for loop would accomplish that task quite fine

Just get the two numbers for it to be between, put them both in a variable and then just use a for loop from the first number to the second and add them to a third number each time.

-----------------------------------
S_Grimm
Wed Oct 08, 2008 10:20 am

RE:how do i make this simple program?
-----------------------------------
but if the program prompts for a user input, an array would be better to store the number

-----------------------------------
gitoxa
Wed Oct 08, 2008 10:17 pm

RE:how do i make this simple program?
-----------------------------------
And how pray tell would you add up the elements of the array? 
With a loop.  Oh shi-

-----------------------------------
isaiahk9
Thu Oct 09, 2008 6:34 am

RE:how do i make this simple program?
-----------------------------------
batgirl13, do you feel ignored?  It seems that we're just arguing one way and another on one trivial item.

This program will not be large, as this may be the only code in the program.  As such, you should take the easiest and slightly less code-efficient route (I beleive) - the for loop.  Like :

Mod Edit: No, we don not give complete answers. Try again next time.

Maybe less code efficient, but way simpler for the person who asked for a simple answer.  Seems everyone in this thread forgot the orignial purpose of this thread - a simple way for the user.

Oh, and this isn't giving code because its riddled with bugs, where making your own would probably be easier than fixing it.

-----------------------------------
ecookman
Wed Oct 15, 2008 11:57 am

RE:how do i make this simple program?
-----------------------------------
could someone help this person instead of arguing what is best it is really annoying. they ask for help and they have to get it through bits and pieces of the loop or an  array.

she asked for somethign simple arrays are hrd to use so i would suguest looops i know this from hands on experience i have only been using turing for 3 weeks now and i don't understand arrays that well but putting loop at the start of a repeating area and a end loop at the end of it or a exit when that is simple

hope that helped

and stop arguing on a forum do that with personal messages!

-----------------------------------
Insectoid
Wed Oct 15, 2008 12:55 pm

RE:how do i make this simple program?
-----------------------------------
First, don't tell us what to do. Judging from your previous posts, you have no idea how uncomplicated this is, though for you it may seem complicated, as you can't even figure out how to draw a simple circle. Oh, and I see your spelling hasn't improved? 

Anywho, there have been multiple ways to do this, so we have already helped her. We are now arguing about the best way to do it, which is something we as programmers enjoy. Private messages are for specific requests to a user, friendly conversation, or other such things that only occur between 2 users. This is an open, public argument for which many arguments may be expressed, and thus may not be confined to PMing. 

~Insectoid. 

PS, Might as well lock this thread...

-----------------------------------
Clayton
Wed Oct 15, 2008 2:28 pm

RE:how do i make this simple program?
-----------------------------------
Alright, that's enough. Both of you have been warned for flaming, and this topic is going to be locked. If the OP wants to again, they can repost the question. End of story.

:locked:
