The program requires an integer input from a user at the command args and prints out the numbers backward. I have this so far, however, it only prints 1 number, which is the number entered into args.
public class KashiwabaraNicole7
{
/*******************************************************************************
* Initializes program
* @ param commandlineArguments
********************************************************************************/
public static void main(String[] commandlineArguments)
{
if (commandlineArguments.length == 0) {
System.out.print("Error: You must enter at least 1 commandline argument ");
}
else
{
Integer number = new Integer(0); //initialize number
try // check to verify if input is an integer
{
number = Integer.parseInt(commandlineArguments[0]);
}
catch (NumberFormatException exception) // NumberFormatException
{
System.out.print(exception);
System.out.println(" is not an integer");
System.exit(1); // end program
}
Integer num = KashiwabaraNicole7.stars(number); //A (return address)
System.out.print(num+",");
}
}
/**
* Writes a character string backward using recursion.
* @param string a character string
* @returns a backwards string
*/
public static int stars(Integer number)
{
String asterisk = "*";
for(int i= number; i>=0;i--)
{
return i;
}
return number;
}
}//end of class