java - While loops in an if statement -


If a user enters more than 10 numbers and is "less than 10, then

to display" greater than 10 "

"Seven times, if the user enters less than 10 numbers. I am capable of displaying "at least 10" but I think what to do next I

public static zero main (string agr []) {scanner sc = new scanner ( System.in); Int num; Int i = 0; System.out.print ("Please enter a number:"); Num = sc.nextInt (); If (digits> <10) {while (i <7) {System.out.println ("less than 10"); I ++; }}

I know that I am screwing somewhere with the counter variable 'I', but I have been looking for it for so long, my brain has been fried. Anyone able to help with this issue? Also, yes if I am restricted to statements and when loops.

Use another "if" (since you only prefer if you prefer to use ) Structure for more than 10 For a given input it will only enter if one of the structures. (You have the option of using "otherwise if")

  Public static zero main (string array []) {scanner sc = new Scanner (System.in); Int num; Int i = 0; System.out.print ("Please enter a number:"); Num = sc.nextInt (); If (digits> <10) {while (i <7) {System.out.println ("less than 10"); I ++; }} If (numerals> 10) {while (i <4) {System.out.println ("more than 10"); I ++; }}}  

Comments