Sunday, November 30, 2014

Help with loops!








I'm doing a program where a user enters in exam results for students. Once he's entered the code, the code should split the results in stars in 4 categories.








I need help with a while loop that prints out infinite results. What I want to do is, if the user enters 2 digits, say "12", it should output 1 "*".








if the user enters "21" and "22", it should output "**".








EDIT: More info








there are 4 categories of marks which are marked with ints range1, range2, range3 and range4, which are user enter digits. Part 1 of the code is to split the user entered digits into its correct ranges. the ranges are 0-29, 30-39, 40-69 and 70-100. I've done the part where when the user enters a digit, it goes into the correct variable. After that when the user enters a digit over 100, the enter results should show up as stars. For example








Enter number =







21







22







44







66







44







23







11







111 (the 111 is where the program breaks and moves on)








so it should then display








0-29 ****







30-39







40-69 ***







70-100








whatever I'm trying, it displays an infinite amount of stars. If I try to use break, It only outputs a single star, no matter how many digits I enter















No comments:

Post a Comment