Help on converting string to an integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baden
    New Member
    • Apr 2007
    • 6

    #1

    Help on converting string to an integer

    I want to convert a string( "A+", "A", "A-") into and integer (4)...
    ( "B+", "B", "B-") into (3) and so on...

    Basically a user will inputs a letter grade into an input dialog and i want to convert that letter grade into a numeric number(GPA).
  • Ganon11
    Recognized Expert Specialist
    • Oct 2006
    • 3651

    #2
    OK, what can you think of to do this?

    Also, please don't double post your question. The thread in Software Development has been deleted.

    Comment

    • Kulbir Singh
      New Member
      • Apr 2007
      • 2

      #3
      Hi,

      just try with this. hope this snippest will solve ur purpose.

      int i = 10;
      String d = String.valueOf( i);
      System.out.prin tln(d);
      int j = Integer.valueOf (d);
      System.out.prin tln(j);

      cheers
      Kulbir Singh

      Comment

      • sateesht
        New Member
        • Apr 2007
        • 41

        #4
        Hi
        Just try with this to Convert a String to an integer::

        String i="10";
        system.out.prin tln(Integer.par seInt(i));

        so we can use the Integer.parseIn t(String) method to Convert the String into an Integer.


        Cheers,
        Sateesh

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by sateesht
          Hi
          Just try with this to Convert a String to an integer::

          String i="10";
          system.out.prin tln(Integer.par seInt(i));

          so we can use the Integer.parseIn t(String) method to Convert the String into an Integer.


          Cheers,
          Sateesh
          An "A-" or a "B+" doesn't make up a nice integer. The OP should use a simple
          Map<String, Integer> for that.

          kind regards,

          Jos

          Comment

          Working...