Skip to content

Instantly share code, notes, and snippets.

@bytecodeman bytecodeman/ Secret
Created Nov 1, 2018

What would you like to do?
CSC-111 Starter Code for In-class Sum Digits Challenge
import java.util.Scanner;
public class SumDigits {
public static void main(String[] args) {
System.out.println("Welcome to the Sum Digits Solver!");
Scanner input = new Scanner(;
int number;
do {
System.out.print("Enter a positive number: ");
number = input.nextInt();
if (number < 0)
System.out.println("Come on pheeb. Enter a positive number!");
} while (number < 0);
// Now enter your code here to calculate the sum of the digits in number
// i.e. number = 2347 Sum of Digits = 16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.