String pattern = "0.";
String decis = null;
//now we're setting up the Scanner to read user inputs
Scanner input = new Scanner(System.in);
/*the written out prompts for program's ease of use and setting
input results as usable variables
*/
System.out.println ("please input a number to square.");
number = input.nextDouble();
System.out.println ("to how many places?");
places = input.nextInt();
//the math operation to be carried out by the program,
//could have been more complex if desired
square = (number * number);
//for-loop to concatenate the string "decis" "place" # of times to itself
for (decimal = 1; decimal <= places; decimal++ ){
decis += ("#");
}
//DecimalFormat made by concatenating 2 strings
DecimalFormat fmt = new DecimalFormat (pattern + decis);
System.out.println ("the square of " + (number) + " is " + fmt.format(square));
}
}