Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.
Index -> Programming, Turing -> Turing Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Velocity




PostPosted: Tue Nov 08, 2011 6:46 pm   Post subject: 5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Pretty much they the assignment im working on is asking me to multiply the even numbers generated by 2 and then add them up to make one value.
I am really stumped on how to do this. This is the code that i have written so far, dont mind the variables that i declared.

Turing:


var number : real
var step1, step2, step3, step4, step5, step6 : int

for ctr : 1 .. 10
    put ctr
end for

put "Then the even number from 1 - 10 are generated."
Time.Delay (5000)
cls


for ctr1 : 2 .. 10 by 2
    step1 := ctr1
    put step1
    Time.Delay (5000)
    step2 := ctr1
    step2 = step2 * 2
    put step2
end for


Sponsor
Sponsor
Sponsor
sponsor
Velocity




PostPosted: Tue Nov 08, 2011 6:48 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

in the second for statement
When it says:
step2 := ctr1
step2 := step2 * 2
put step2

I got confused, because i am unsure how to multiply the ctr1 numbers without hae a 2 come out in the outcome.
Velocity




PostPosted: Tue Nov 08, 2011 6:56 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Bump!
Still looking for help.
Velocity




PostPosted: Tue Nov 08, 2011 7:00 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

10 bits to helper! Fast please help.
ProgrammingFun




PostPosted: Tue Nov 08, 2011 7:09 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Can you give the exact question? I don't understand what you're trying to do..

And stop multi-posting, it won't get anyone to respond faster...
Velocity




PostPosted: Tue Nov 08, 2011 7:27 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

6. Everyone has a nine digit Social Insurance Number (SIN) which is issued by the government. The government follows a certain method when issuing the SIN numbers so that they can check if they are valid or not. THe steps used to check that a SIN number is valid are as follows:
1) Create a four digit number by taking the digits in the even numbered positions.

2) multiply this number by 2 to create a five digit number

3) add the digits of this number together
( = evenSum)

4) add the digits in the odd numbered positions 1, 3, 5 & 7 (= oddSum)

5) take the units digit (ones digit) from the sum of evenSum and oddSum and subtract it from 10

6) the absolute value of the resulting number from the last step should equal to the value of digit 9

write a program that inputs a SIN number, cheecks to see if it is valid and outputs an apprpriate message.

NOTE : The SIN number is 9 digit number

<< sorry for reposting, i didnt intend to get anyone to post faster, i was just trying to let people know that i am still here, and am still looking for help.
Tony




PostPosted: Tue Nov 08, 2011 7:40 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

So then, how far into the question are you? The posted code doesn't seem to be applicable to any of the steps.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Velocity




PostPosted: Tue Nov 08, 2011 7:49 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

That's the thing. I dont understand how to complete the question.

I assumed that i was on step 2, but apparently not?
Sponsor
Sponsor
Sponsor
sponsor
Aange10




PostPosted: Tue Nov 08, 2011 7:52 pm   Post subject: Re: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Velocity @ 8/11/2011, 6:27 pm wrote:
6.
6) the absolute value of the resulting number from the last step should equal to the value of digit 9


Okay, so I assume you have completed all the steps up to 6. (Considering that is the number at the top of your response).
So, you will need to have two things here. The resulting number of step 5 and the value of the 9th digit.
Now, what does absolute value mean? http://en.wikipedia.org/wiki/Absolute_value

Now that we know that, we can continue with the coding. So, the way a number in absolute value works is if the number is positive, then there is no change, where as if the number is negative, then the value is changed to positive (technically to no sign).

Given that information, how would we implement that into coding?


*TIP: ANumber > 0 is Positive, and ANumber < 0 is Negative.

*SPOILER* Helpful code is posted below, if you'd like to see it, highlight it. -- Also, if it is another step you need help on, let me know. I figure you need help on this one because it is at the top of you're response.


% Using Absolute Value
if step_5_value >= 0 then

elsif step_5_value < 0 then
step_5_value := (step_5_value * -1)
end if

%Checking Number
if step_5_value = digit_9 then
put "Step_5_Value is equal to Digit_9!"
else
put "Step_5_Value is NOT equal to Digit_9!"
end if
Aange10




PostPosted: Tue Nov 08, 2011 7:53 pm   Post subject: Re: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Velocity @ 8/11/2011, 6:49 pm wrote:
That's the thing. I dont understand how to complete the question.

I assumed that i was on step 2, but apparently not?



Ahh, sorry. This post came after I replied before, but then I take it you are on step 2?
Tony




PostPosted: Tue Nov 08, 2011 7:56 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Step 1.
Given a 9 digit SIN, take the even digit positions to form a new number. That is:
123456789 => 2468

Do you have that done?
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Aange10




PostPosted: Tue Nov 08, 2011 8:07 pm   Post subject: Re: 5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Quote:

1) Create a four digit number by taking the digits in the even numbered positions.


Okay so step one should be simple. Simply take the numbers from the nine digit code that are in an even spot. For this help session I'm going to use the code 123456789 as my Sin code.

So we should declare our variables, SIN_digit_1, SIN_digit_2, digit_3 ... SIN_digit_9. (If you know Arrays, than do that as it would make things a lot easier). Now, what are the even positions of the nine digit code? 2,4,6, and 8 of course. For our example, it just so happens that our number for step 1 is 2468.

I suggest you store this information as step_1 for later use.

Quote:

2) multiply this number by 2 to create a five digit number


Aha! Good thing we stored step_1 as a variable! Now, this should be simple. Take step_1 and multiply it by 2!

I'd store the results as step_2_digit_1 .. step_2_digit_5 (etc.) for later use. **Note, it is obvious 123456789 is not a valid code. But we can still work using this example.

Quote:

3) add the digits of this number together
( = evenSum)


Great thing we saved each digit, huh? Now this is easy! Just add each digit of step 2.

I'd store the results as step_3, and as evenSum (because the program tells you to. Later you could go back and remove step_3, but for now it is easy referencing.)

Quote:

4) add the digits in the odd numbered positions 1, 3, 5 & 7 (= oddSum)


Now, considering it says there are 7+ digits, I'll assume it's talking about the original SIN code. (Considering that in step 2 our outcome should have been 5 digits, not seven.)

This should be easy as well, all we have to do is add SIN_digit_1, 3, 5, and 7!

I'd save this as step_4 and as oddSum.

Getting easier, right?

Quote:

5) take the units digit (ones digit) from the sum of evenSum and oddSum and subtract it from 10


This should be super simple. All we have to do is add evenSum and oddSum and subtract it from 10.

I'd save this as step_5.


I've already explained step 6, and the messages should be simple to figure out now that you have the actual math done! However, if you still need help, feel free to ask!


**ALSO if you know Arrays, it would be wise to store all this data in arrays.
Velocity




PostPosted: Tue Nov 08, 2011 8:12 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

@ Tony - Yes
@ Aange im still reading your post.
Aange10




PostPosted: Tue Nov 08, 2011 8:23 pm   Post subject: Re: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Also
Velocity @ 8/11/2011, 6:00 pm wrote:
10 bits to helper! Fast please help.


Most of us do this for fun, because we enjoy helping others, and the general practice of programming.


And Karma is nice (:
Velocity




PostPosted: Tue Nov 08, 2011 8:31 pm   Post subject: RE:5+ bits the helper (please do not answer it for me, i only need help) I want to know how to do this next time.

Two things @ Aange
1) How do you add numbers inside an array?
2) They also ask us to write a program that inputs a SIN number, checks to see if it is a valid SIN number and outputs an appropriate message (how would i input my program into that?)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 29 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: