Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


need help

rebelxdrebelxd Posts: 8
i am making a program that asks the user to enter a password nd then The program finds the total of adding the integer value (ASCII value) of each of the characters in the password,, so if the user entered "dog" as the password
d has ASCII value 100
o has ASCII value 111
g has ASCII value 103
So d + o + g = 100 + 111 + 103 = 314

i am having a problem adding the ascii values can some1 plz help me?

this is my code so far
System.out.print("What is the password>. ");
phrase = keyboard.nextLine();

for(int i =0; i <phrase.length(); ++i)
char a = phrase.charAt();
int b = (int) a;


  • The only issue i see is that the for loop does not accumulate the value of each character.
    i.e. passwordTotal = passwordTotal + b;

    The passwordTotal must be defined and initialized [u]before[/u] entering the for loop.

Sign In or Register to comment.