I was working on homework assignments about making a program that allows the user to enter in a low and high value range and the program was suppose to find all the numbers that were sum of their cubed digits (IE 153 = 1^3 + 5^3 + 3^3) and a for loop has to be used. I'm stuck on figuring out how to go about this, I obviously need to separate each digit of the number take each digit cube it, add them together then check to see if it equals the value if not repeat but that's as far as I have gotten planning wise help would be appreciated.
/*
* problem #17 on page 367
* Program Description - finding numbers that equal the sum of their cubed numbers
* Author: Jonathan Wilson
* Date: 2/24/2015
* Filename: cube.java
*/
//import statements
import java.util.*; //for scanner class
// class beginning
class Cube {
public static void main(String[] args ) {
//Declare variables area
int low;
int high;
int value;
Scanner scan = new Scanner (System.in);
//Program beginning messages to user here
System.out.println("Welcome to my special number program!");
System.out.println("Enter a low and high value range");
System.out.println("and this program will find all the numbers that equal the sum of their cubed digits");
//Collect inputs from user or read in data here
System.out.println("Enter in the low starting range ");
low=scan.nextInt(); //storing low range as low
System.out.println(); //break
System.out.println("Enter in the high ending range ");
high=scan.nextInt(); //storing the high range as high
System.out.println(); //break
// A check to see that the range entered is a legal range, if so then it moves on to print out range and goes
// into main code
while (high < low){//checks to see if the inputs are valid and that the user doesn't try to do an inverse range
System.out.println();
System.out.println("Incorrect Range try again!");
System.out.
low = scan.nextInt();
System.out.print(Low);
System.out.println();//break
System.out.print("Please enter the higher number in the range... ");
high = scan.nextInt();
//Echo input values back to user here
System.out.println("Okay, so the range of numbers to look through are "+Low+ " to "+High+" lets start!");
// Main code and calculations to do
for (count= low; count <= high; count ++){
//Output results here
//End program message
System.out.println();
System.out.println("Hope you enjoyed using this program!");
}// end main method
}
}
}// end class