Results 1 to 4 of 4
  1. #1
    Katnopic is offline Member
    Join Date
    Sep 2012
    Rep Power

    Default String related java question

    In a H.W exercise ive got a question to create a string full of numbers, and then print the average score of those numbers.. problem is i tried it and the following code counts the numbers as their ascii value:

    String s ;
    int agg = 0, count = 0;
    s = "1234234324";
    for (int i = 0; i < s.length(); i++)

    agg += s.charAt(i);
    System.out.println(+ agg/count);

    Ive tried to covert the char type to int but it still gives me iscii.. so the question is, how do i covert a char number into an int of the number?

  2. #2
    milovan is offline Senior Member
    Join Date
    Jan 2011
    Belgrade, Serbia
    Rep Power

    Default Re: String related java question

    Could you show us how you tried to convert char into int?

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Madgaon, Goa, India
    Rep Power

    Default Re: String related java question

    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Rep Power

    Default Re: String related java question

    The API is your friend.

    Keep hold of that API link.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 8
    Last Post: 08-11-2012, 07:18 PM
  2. Replies: 1
    Last Post: 04-27-2012, 07:14 AM
  3. Question related to JSTL attributes
    By neerajrathi2 in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 01-31-2012, 07:32 PM
  4. Java String Digit Question
    By toaster_man in forum New To Java
    Replies: 5
    Last Post: 12-12-2010, 09:08 PM
  5. Question related to htmlParser
    By java_org_bsb in forum New To Java
    Replies: 1
    Last Post: 02-01-2009, 02:42 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts