|
[Java] Sum of letters in sentence.
|
|
08-14-2009, 11:43 AM
Post: #1
|
|||
|
|||
|
[Java] Sum of letters in sentence.
A challenge from over at freelancecode (.net).
Quote:Given the following information: Code: /** |
|||
|
08-14-2009, 12:19 PM
(This post was last modified: 08-14-2009 01:10 PM by G4143.)
Post: #2
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
I'll take a look at this Tonight or tomorrow. The solution will be in C...G4143
I think this will meet the requirements. I got a total of 450...G4143 Code: #include <stdio.h> |
|||
|
08-14-2009, 05:44 PM
Post: #3
|
|||
|
|||
RE: [Java] Sum of letters in sentence.
(08-14-2009 11:43 AM)Sketch Wrote: A challenge from over at freelancecode (.net). Ah that's exactly what i did in pascal basically lol apparently this way isn't the best i like G4143's way the best "Character is determined more by the lack of certain experiences than by those one has had." Friedrich Nietzsche |
|||
|
08-14-2009, 05:59 PM
(This post was last modified: 08-14-2009 06:00 PM by drdebcol.)
Post: #4
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
Interesting programming assignment ! Sketch did it in java using, i can say, bruteforce writing, because he wrote everything and summed it up !
G4143 did it in C++ using ASCII and return functions from it - i like it ! Now i want to add my solution in Pascal which is not like two past solutions, i used set of checking and char loop ! Most of Pascal programmers don't know this exist : Code: program sum_of_letters;"I dont know with what weapons World War 3 will be fought with, but i know World War 4 will be fought with stones and sticks" - Albert Einstein |
|||
|
08-14-2009, 10:20 PM
Post: #5
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
Yeah, the best way would be to use a loop, and assign each letter a value through the loop.
Then print out the sum of it all. And yep, my answer was also 450 ![]() Keep it up guys! |
|||
|
09-23-2009, 11:06 AM
Post: #6
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
There's an easier way to do it. The sentence 'the quick brown fox jumps over the lazy dog' uses each letter of the alphabet once. Only once. Knowing that, you could've used a for() loop and just added the values from 1 to 26.
|
|||
|
09-23-2009, 06:41 PM
Post: #7
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
Thats well spotted there. I don't code Java now anymore. Into C#.
But thanks! |
|||
|
12-09-2009, 08:14 AM
Post: #8
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
I think I'd probably do this one like oToom.
![]() Now a challenge would be to make it for any entered sentence. I will do it when I get the opportunity.
![]()
|
|||
|
12-09-2009, 08:28 AM
Post: #9
|
|||
|
|||
|
RE: [Java] Sum of letters in sentence.
I did a java and c++ solution here. http://www.freelancecode.net/community/v...?f=13&t=11
|
|||
|
« Next Oldest | Next Newest »
|












![[Image: 45669_pythonlogo.png]](http://myph.us/pics/45669_pythonlogo.png)
