I'm writing a program where it asks a user a number between a range and then displays $ the number of times of the number entered.
But I'm needing to have this repeat 5 times (or more if an invalid number is entered).
EDIT:::: Got the repeat fixed, just needing to have it repeat if it goes to the else statement.
Here is my code so far.
But I'm needing to have this repeat 5 times (or more if an invalid number is entered).
EDIT:::: Got the repeat fixed, just needing to have it repeat if it goes to the else statement.
Here is my code so far.
Code:
import java.util.Scanner;
public class Lab7_Ex1
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int x;
int count=1;
for (count = 5; count<=5; count++)
{
System.out.print("Enter an integer in the range 1-10: ");
x = keyboard.nextInt();
if ( x >= 1 && x <= 10)
{
for (int i = 1; x<=1; i++);
{
for (int j = 1; j <= x; j++)
{
System.out.print('$');
}
System.out.println();
}
}
else
{
System.out.println("Invalid number");
}
}
}
}
Comment