Results 1 to 5 of 5
Thread: add ascii values together
- 05-02-2010, 04:42 PM #1
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
add ascii values together
hey guys im trying to find a way to add all the ascii values the are outputted by this loop
at the moment each individual ascii value is outputted to the screen, but i want it to add all the ascii values together in one integer. how do i do this? Thanks for the helpJava Code:for (int i=0; i < word.length(); i++) { char c = word.charAt(i); int j = (int) c; System.out.println("ASCII of: "+ c +" = " + j); }
- 05-02-2010, 05:01 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,405
- Blog Entries
- 7
- Rep Power
- 17
- 05-03-2010, 12:23 AM #3
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
Yes that is what i am trying to do but im not sure how to type it up, thanks for the help
- 05-03-2010, 12:57 AM #4
Member
- Join Date
- May 2010
- Posts
- 9
- Rep Power
- 0
it is a very simple problem.Java Code:int total = 0; for (int i=0; i < word.length(); i++) { char c = word.charAt(i); int j = (int) c; total += c; System.out.println("ASCII of: "+ c +" = " + j); } System.out.println(total);
here you go
the
total += c;
function i used translates in java to
total = total + c;
useful to know.
- 05-03-2010, 01:09 AM #5
Member
- Join Date
- Apr 2010
- Posts
- 7
- Rep Power
- 0
Similar Threads
-
Binary and ASCII
By mac in forum New To JavaReplies: 4Last Post: 01-10-2010, 06:31 PM -
HashMap contains all values but doesn't show all values
By xcallmejudasx in forum New To JavaReplies: 3Last Post: 05-10-2009, 11:35 PM -
Retaining DB values as well as Dynamically generated Values.. Help Needed !
By rajivjha in forum Advanced JavaReplies: 0Last Post: 05-22-2008, 10:53 AM -
Accessing boolean Values of another values in one class.
By a_iyer20 in forum Advanced JavaReplies: 4Last Post: 04-15-2008, 01:04 PM -
Printing ASCII values of characters
By Java Tip in forum Java TipReplies: 0Last Post: 01-21-2008, 04:36 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks