260 likes | 365 Views
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println ("Your response should have been positive.") ; println ("You're no fun to play number games with.");
E N D
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); }
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); }
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 0
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 0 n 1729
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 0 n 1729
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 0 n 1729 9 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 9 n 1729 9 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 9 n 172 9 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 9 n 172
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 9 n 172 2 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 11 n 172 2 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 11 n 17 2 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 11 n 17
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 11 n 17 7 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 18 n 17 7 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 18 n 1 7 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 18 n 1 7 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 18 n 1
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 18 n 1 1 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 19 n 1 1 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 19 n 0 1 digit
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 19 n 0
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 19 n 0
/** * File: DigitSum.java */ public void run() { int number = readInt("Enter a number greater than 0: "); if (number <= 0) { println("Your response should have been positive."); println("You're no fun to play number games with."); return; // end prematurely without continuing } int digitSum = 0; int n = number; while (n > 0) { int digit = n % 10; digitSum += digit; n /= 10; } println("The sum of the digits making up " + number + " is " + digitSum + "."); println("Thanks for playing. :)"); } number 1729 digitSum 19 n 0