Search for question
Question

CIT129 Introduction to Programming - Spring 2024 Assignment #5 (based on chapter 6 of your textbook) – 100 points Date Assigned: 2/12 ● ● ● DO NOT post the text of this assignment on any web sites. DO NOT share your answers with anyone. DO NOT collaborate on completing work with anyone. DO NOT use the Internet to search for solution to assignments. DO NOT pay anyone to write your code. Avoid web sites that offer solutions to assignments. These include AI tools such as ChatGPT, chegg.com, CourseHero, etc. If you copy work from such web sites, keep in mind that other students are also looking at the same information and will therefore submit duplicated work. Failure to meet these requirements leads to the violation of the academic integrity principles as stated in your syllabus. Objective: Demonstrate your understanding of solving problems that involve using nested loops and decisions in programs. Assignment: Write Raptor code to process student age values. Deliverable: One Raptor code files (.rap). Save your file using the format: firstNameLastNameCIT129_pa5.rap. Submit the file through the Canvas Assignment dropbox. Date Due: 2/20 Documentation: I am also asking for code documentation. I explained the process in our last assignment. I hope you understand that code documentation is different than output from programs. Code documentation explain the code, output show the interaction of the code with the user. NOTE: There is no need to submit your pseudocode file. It's always best to start with one, but you would not submit it. Process: The program: a) Asks for a password. b) If the password is not "123", the program issues an error message and terminates. HINT: This is a simple decision structure. If the password is 123: CIT129 - Assignment 5 - Chapter 6 (more loops and decisions) Page 1 i. ii. Ask the user for the number of students. Validate the input so that the input number is within 1 and 100 students. If the number of students is out of this range, allow the student to enter another number until we have a "good" number of students. For each student: a. b. Ask the user for the student's age in years. Do not allow the user to enter an invalid age (A number less than 1 or more than 120 is invalid). Issue an error message and allow the user to enter a valid age. Display the age along with the message "that is odd” if the age is odd, otherwise, display the age along with the message "you are even" c. Calculate and display the total of all even age values in years. d. Calculate and display the total of all odd age values in years. e. Calculate and display the total age of all students in years. f. Find and display the lowest age value in years. g. Find and display the highest age value in years. h. Calculate and display the average age for all students in years and in days. Assume 365 days in a year. == Hint: Using the MOD function might come in handy for determining if a number is even or odd. IF num MOD 2 1 then it must be ODD. If num MOD 2= 0 then must be even. So, if num happens to happen to be 13, 13 MOD 2 = 1, so 13 is odd. Recall that the MOD operator in Raptor gives you the remainder of division of 2 whole numbers. == Here are sample test cases: <<<< These are just sample runs - your code must work in all situations. Enter the password: 777 Wrong password! - I'm terminating Enter the password: 123 Enter the number of students: -1 Invalid - try again Enter the number of students: -5 Invalid - try again Enter the number of students: 1000 Invalid - try again Enter the number of students: 3 Enter the age of the student: 20 20 you are even Enter the age of the student: -1 Invalid - try again CIT129 - Assignment 5 - Chapter 6 (more loops and decisions) Page 2 Enter the age of the student: 130 Invalid – try again Enter the age of the student: 30 30 you are even Enter the age of the student: 15 15 that is odd Total of even age values = 50 Total of even odd values = 15 Total age in years = 65 Lowest age in years = 15 Highest age in years 30 Average age in years = 21.6667 Average age in days = 7908.3333 - CIT129 - Assignment 5 - Chapter 6 (more loops and decisions) Page 3