|
-
February 16th, 2009, 03:02 PM
#1
stumped on do while loops
Having a little trouble creating a program.. Well to start I need to create a program that will list all of the numbers between two input values, in either ascending or descending order. The user will enter a lower bound and upper bound number through a scanner object, and enter whether they want Ascending or Descending via A/a or D/d. if the user enters an incorrect A/a or D/d the user will be stated error or what not.. but here is my code.. any help would be greatly appreciated. thank you.
Code:
import java.util.Scanner;
public class assign4
{
public static void main(String[] args)
{
int low, up;
Scanner input = new Scanner(System.in);
String A, a, D, d, check;
do
{
System.out.print("Enter lower bound integer: ");
low = input.nextInt();
System.out.print("Enter upper bound integer: ");
up = input.nextInt();
System.out.println("Lower bound: " + low);
System.out.println("Upper bound: " + up);
}
while (low <= up);
{
System.out.println("Error!! lower bound must be smaller.");
}
System.out.print("Would you like Ascending or Descending order? [A/a or D/d]: ");
A = input.check;
a = input.check;
D = input.check;
d = input.check;
while (check.equals("A,a"));
{
System.out.println(low + 1);
}
while (check.equals("D,d"));
{
System.out.println(top - 1);
}
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|