ISAEmjr 0 Newbie Poster

branch between three sets of statements: One to display the numbers in descending order from the upper bound down to the lower bound (executed on character input 'd' or 'D'), one to display the numbers in ascending order from the lower bound up to the upper bound (executed on character input 'a' or 'A'), and one that just displays the message "Illegal direction." (executed on all other character inputs). (Use an if-else or a switch statement here.)

However, i keep only finding things using arrays. Maybe I am overlooking something in the book! Please help here is my code thus far

import java.util.*;


public class Ascending
{
	static Scanner console = new Scanner(System.in);
	public static void main(String[] args)
	{

				//declarations


	int number1;
	int number2;
	char answer;



				//do loop
	do
	{
				//Prompts user for numbers & Reads in values
 		System.out.println("Enter lower bound:");
 		number1 = console.nextInt();
 		System.out.println("Enter upper bound:");
		number2 = console.nextInt();
		System.out.println();
	}
				//while loop
	while (number1 < number2);
			System.out.println("ERROR: upper bound is smaller than lower bound");
			System.out.println();
				// end while loop

	if (number1 <= number2);
		System.out.println("Enter lower bound:");
		number1 = console.nextInt();
		System.out.println("Enter upper bound:");
		number2 = console.nextInt();
		System.out.println("Ascending (A/a) or Descending (D/d)?");
		answer = console.next().charAt(0); // reads in user response

		   if ((answer == 'a') || (answer == 'A'))//checks to see if users response is a / A
		   {


		   }//end if

		   else {
			   if ((answer == 'd') || (answer == 'D'))//checks to see if users response is d / D
			   {


			  }//end if

		   }//end else



	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.