r/ProgrammingPrompts • u/FlamingSnipers • Feb 11 '16
[Easy] Make an ASCII Summation Calculator
Write a program that takes in a string from the user (or if you want, a file!) and prints all the characters' ascii values summed up to the user.
For Example: The above paragraph's ascii sum is 13,156
Edit: It is actually 13,124 thanks /u/Answers_With_Java, I ran my program again and I got that as well, I dunno why I wrote 13,156
5
Upvotes
2
u/Answers_With_Java Feb 11 '16 edited Feb 11 '16
Wrote my answer using Java (of course).
I tried inputting the same thing you did for your example and I got 13124 for my answer. I tried looking up an ascii chart and checking my results for individual characters and it was correct.
Output:
5
u/Philboyd_Studge Feb 12 '16
4
u/kotrenn Feb 12 '16
The difference between your two answers is 32, which is a space in ASCII. So maybe you just had an extra space the first time you ran it?
1
u/dMenche Feb 12 '16
R7RS Scheme:
This could definitely be refined a bit.
1
u/ANAL_CHAKRA Feb 20 '16
Simple one in python3:
http://pastebin.com/rpCBYZkp
1
u/rajjjjk Mar 18 '16
In Python.
1
u/JakDrako Apr 02 '16
VB
File version
1
u/turbot151 Apr 10 '16
Little late to the game. I'm new to programming so tell me if there is anything to fix in the code.
[C#]
Output:
Skip to the last one.
1
u/BumFudhe Apr 23 '16
Python function:
1
u/projectisaac Apr 28 '16
I believe this will give us the answer we want in C#:
It ran fine for me!
1
u/LESkidd113 Jul 01 '16
Hey guys here's another answer in Java. Any comments?