String numOfTermsInput = JOptionPane.showInputDialog(null, "Please enter the number "
+ "of terms you would like to use to compute Pi: ");
Scanner numOfTermsScanner = new Scanner(numOfTermsInput);
int term = numOfTermsScanner.nextInt();
numOfTermsScanner.close();
int num1 = term * 2;
int num2 = num1 + 1;
int num3 = num2 + 1;
int digit1 = num1 * 1000;
int digit2 = num2 * 10;
int digit3 = num3;
int sum = digit1 + digit2 + digit3;
if (digit3 > 9)
{
sum = ((digit1 + digit2) * 10) + digit3;
}
System.out.println(digit1);
System.out.println(digit2);
System.out.println(digit3);
System.out.println(sum);
I want to try and consider the numbers as characters, so that when I get 8, 9, 10 the value will be 8910, or is there a more efficient way to do this? You can ignore the if statement, that was just an attempt and only works for 8910. Thanks.