Question
PROGRAM 2
A 5th grade teacher has measured the height (in inches) of 10 students in her class. Write a program that uses a loop to read the heights from the keyboard and store the heights in an array. Find and display the height of the shortest student in the whole class.
TEST CASE
INPUT EXPECTED OUTPUT
Heights:
62 61 59 64 60
54 57 53 60 55
Height of shortest student: 53
Explanation / Answer
bool isSelected[3] = { TRUE, FALSE, FALSE }; short int selection = 0; int DrawGLScene(GLvoid) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslatef(0.0f,0.0f,-1.0f); glColor3f(0.0f, 0.0f, isSelected[0] ? 1.0f : 0.5f); glRasterPos2f(-0.1f, 0.1f); glPrint("New Game"); glColor3f(0.0f, 0.0f, isSelected[1] ? 1.0f : 0.5f); glRasterPos2f(-0.1f, 0.0f); glPrint("Load Game"); glColor3f(0.0f, 0.0f, isSelected[2] ? 1.0f : 0.5f); glRasterPos2f(-0.1f, -0.1f); glPrint("Exit Game"); return TRUE; } if (UP is pressed) { isSelected[selection] = !isSelected[selection]; if (selection > 0) selection = selection - 1; else selection = 2; isSelected[selection] = !isSelected[selection]; } if (DOWN is pressed) { isSelected[selection] = !isSelected[selection]; if (selection < 2) selection = selection + 1; else selection = 0; isSelected[selection] = !isSelected[selection]; } if (ENTER is pressed) { switch (selection) { case 0: NewGame(); case 1: LoadGame(); case 2: return 0; } }