Think about the test condition:
while(n>0 && n<8)
It says that if the value is from 1 to 7 inclusive, repeat the loop. But, you really want to repeat the loop if the value of n doesn't meet the conditions.
In this situation, you actually want to test for the opposite of the values that you want.
BTW, what happens if n IS 8? Think about it. ;-)
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)