I want to be able to separate a String of two numbers and then add them together, but I keep getting the int
value of each character. If I enter "55" as a string I want the answer to be 10. How can I do that?
package org.eclipse.wb.swt;
import java.util.*;
public class ISBN13 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("enter a string");
String numbers = input.nextLine(); //String would be 55
int num1=numbers.charAt(0); //5
int num2=numbers.charAt(1); //5
System.out.println(num1+num2); //the answer should be 10
}
}