Thread: h
-
Jun 24th, 2020, 10:28 AM
#1
Thread Starter
New Member
Last edited by brycekrispy; Jun 24th, 2020 at 11:24 AM.
-
Jun 24th, 2020, 10:41 AM
#2
Re: How do I create a sum function?
If you were doing this for real then you'd do it like this:
vb.net Code:
Dim sum = Enumerable.Range(1, x).Sum()
I suspect that this is homework and you are supposed to show that you can write a loop though. If that is the case then it would be cheating for us to write the code for you. Maybe you should review the information you've been taught, put it to use and try writing the code for yourself. If you have problems along the way then we can help with that but you do still need to do your own homework for the most part. If you really wanted to cheat though, I can't imagine that it would be hard to find an example of something like this already on the web.
-
Jun 24th, 2020, 10:41 AM
#3
Re: How do I create a sum function?
The mathematical formula for the sum of n numbers is n * (n + 1) / 2. In the post #1 example, n is 5 so the answer is 5 * 6 / 2 which is the required 15.
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jun 24th, 2020, 11:32 AM
#4
Re: h
The edits to the initial post has turned this into an exercise in surrealism.
My usual boring signature: Nothing
-
Jun 24th, 2020, 11:35 AM
#5
Re: h
My answer to this kind of question is generally "between now and later" but has nothing to do with VB...
The best friend of any programmer is a search engine
"Don't wish it was easier, wish you were better. Don't wish for less problems, wish for more skills. Don't wish for less challenges, wish for more wisdom" (J. Rohn)
“They did not know it was impossible so they did it” (Mark Twain)
-
Jun 24th, 2020, 11:43 AM
#6
Re: h
I prefer jmcilhinney's and 2kaud's solutions, but the looping method is...
Code:
Dim sum as Integer = 0
For x as Integer = 1 to 5
sum += x
Next
MsgBox(sum.ToString)
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 24th, 2020, 11:51 AM
#7
Re: h
Originally Posted by .paul.
I prefer jmcilhinney's and 2kaud's solutions, but the looping method is...
Code:
Dim sum as Integer = 0
For x as Integer = 1 to 5
sum += x
Next
MsgBox(sum.ToString)
Why do you insist on cheating for people all the time? As someone who has done plenty of study and has worked for the marks they got and accepted the loss when they couldn't do the work themselves, it's frustrating to see someone continually encourage others to not bother doing their own homework. The only reason someone would need to use a loop when there are better options is because it's homework and they are required to demonstrate some specific coding technique. Why do you think it's a good idea that they get marks for work they didn't even try to do when their classmates who actually did try but may not have been able to do everything themselves will lose marks? It really is infuriating to see this repeatedly. What you do is up to you but I implore you to stop cheating for lazy students. If they are good enough to do the work then they should do it and if they're not then they don't deserve the marks.
-
Jun 24th, 2020, 11:57 AM
#8
Re: h
I've studied hard myself, and i know just how disappointing it is to get worse marks than i hoped for. I wish some of my assignments just asked for a simple loop and a sum. I only answered because it appears the OP has abandoned the thread, and any programmer that doesn't know how to write a simple loop themselves is going to fall flat on their face later if they choose to just copy and paste my answer...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 24th, 2020, 12:05 PM
#9
Re: h
Programming classes build on the subjects taught. A simple loop this week might be a more complex program requiring loops next week. Anyone copying and pasting blindly deserves to fail, and they will eventually.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 24th, 2020, 12:43 PM
#10
Re: h
Originally Posted by .paul.
Programming classes build on the subjects taught. A simple loop this week might be a more complex program requiring loops next week. Anyone copying and pasting blindly deserves to fail, and they will eventually.
Right, but what you are doing is helping to "kick the fail" down the road. If you ran a business that hired entry level programmers straight from college, you wouldn't want to be in a position where you might be hiring someone who copied and pasted their way to a degree. Then their failure is at your expense, when their failure should be at their own expense.
The earlier the fail is acknowledged, the better. For the person, for potential employers, for society.
-
Jun 24th, 2020, 01:17 PM
#11
Re: h
Ok. For a programmer that doesn’t know how to use a simple loop, I’d recommend a beginner’s tutorial...
http://www.homeandlearn.co.uk
BryceKrispy - you obviously didn’t know how to use a loop, and as no-one else here is willing to direct you to a proper explanation of how loops and variables work, I’d strongly recommend working through the tutorial...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 24th, 2020, 01:30 PM
#12
Re: h
Originally Posted by OptionBase1
Right, but what you are doing is helping to "kick the fail" down the road. If you ran a business that hired entry level programmers straight from college, you wouldn't want to be in a position where you might be hiring someone who copied and pasted their way to a degree. Then their failure is at your expense, when their failure should be at their own expense.
The earlier the fail is acknowledged, the better. For the person, for potential employers, for society.
If I ran a business that hired entry level programmers, they’d be required to pass an exam at a suitable level of complexity, as a part of the recruitment process. I wouldn’t take qualifications as proof of anything. I’ve been to plenty of interviews myself where only those who passed an aptitude test got through to the second part of the interview...
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 24th, 2020, 01:32 PM
#13
Re: h
Originally Posted by .paul.
Ok. For a programmer that doesn’t know how to use a simple loop, I’d recommend a beginner’s tutorial...
http://www.homeandlearn.co.uk
BryceKrispy - you obviously didn’t know how to use a loop, and as no-one else here is willing to direct you to a proper explanation of how loops and variables work, I’d strongly recommend working through the tutorial...
If they have been assigned this exercise then they are already, at the very least, working through a tutorial and possibly a book or a class. In any of those cases, they've been taught how to write a loop. They were just too lazy to go back over their text, understand the principles involved and then apply those principles to this specific situation. In the extremely unlikely case that they legitimately haven't encountered instruction on writing a loop before, if someone is not capable of opening a search engine and typing in "vb.net tutorial" then we really think we're doing them or anyone else a favour by encouraging them to get into programming. I know that you want to help but there's a difference between helping and enabling. Again, what you do is up to you - I don't make the rules and you can ignore everything I say if you want - but I have very strong opinions on this subject and felt compelled to voice them because I'm pissed off over a conversation I had online on a different subject so sorry if you suffered some of the splash from that.
-
Jun 24th, 2020, 01:39 PM
#14
Re: h
My last post. You can go another round if you want, I won't respond.
In your scenario, if said applicant elicited help from the internet to pass your complex exam, and someone else with your mindset willingly provided such assistance? Well, I suppose you could do another round of more stringent vetting. And if they got help with that round? And the next round? Yeah...
You're not helping anyone in the long term when you do their work for them. You are obviously free to post whatever you want in homework threads, just don't be surprised when you are criticized for doing their homework for them. Like I said, it is kicking the fail down the road.
-
Jun 24th, 2020, 01:45 PM
#15
Re: h
I have to admit that I Post sometimes to much Information or should I say to much Code, I read what JMC
is saying and I think I'll try and hold back a bit more.
anyway I found a good video Tut. on L(H)oop's for beginners
https://www.youtube.com/watch?v=2ZLuZh2sF9c
the Task for every advanced programmer would be to Hoop and write
a Loop on the Laptop
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Jun 24th, 2020, 01:46 PM
#16
Re: h
@jm and OptionBase You’re right, they could cheat, but I was referring to a pen and paper classroom scenario
Last edited by .paul.; Jun 24th, 2020 at 07:03 PM.
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 24th, 2020, 01:52 PM
#17
Re: h
Originally Posted by ChrisE
I have to admit that I Post sometimes to much Information or should I say to much Code, I read what JMC
is saying and I think I'll try and hold back a bit more.
I'm guilty of it myself at times. It can depend what sort of mood I'm in. I try to gauge whether a question is likely to be homework or not and avoid just posting code to copy if I think it is. That's why I did post the sort of code you might use in a real application but not the sort of code a beginner's homework question would accept. In such cases, I will often ask the sort of questions that I think the person should be asking themselves and the answers can yield a topic that they can then research to come up with the actual answer tot heir original question. Sure, we can post links to tutorials but, to be brutally honest, anyone who can't find that sort of thing for themselves is really too dumb to be a developer or too lazy to deserve anyone's help.
-
Jun 24th, 2020, 06:20 PM
#18
Re: h
For a thread with a question that was almost immediately deleted, this has sure gone on a long time.
My usual boring signature: Nothing
-
Jun 24th, 2020, 09:03 PM
#19
Re: h
Originally Posted by Shaggy Hiker
For a thread with a question that was almost immediately deleted, this has sure gone on a long time.
If the OP is just going to slink off then we may as well get some mileage out of this thread.
-
Jun 27th, 2020, 07:34 AM
#20
Re: h
This is the FAQ on the CodeGuru sister site re homework help.
http://forums.codeguru.com/showthrea...ork-assignment
All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
Jun 27th, 2020, 02:29 PM
#21
Re: h
That's a pretty good summary of the various posts that have been made on this topic over the years.
My usual boring signature: Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|