CSIS 3280 Assignment 1

127 views 8:10 am 0 Comments October 9, 2023

Copyright © 2023 Bambang Sarif. Not for redistribution. Page 1 of 3 CSIS 3280 Assignment 1: A Console App Create a PHP file following the naming convention and PHP standard recommendation (see the work submission guideline document) You are required to write a console application to calculate students’ weighted assignment score and their feedback. Note that there are four students’ records where the three assignment scores are generated randomly. The user can choose to re-run the appsseveral times. You need to define some constant and create some functions as stated in the requirement below. You must follow the good programming practices we have in the class. Note: functions need to be created in a separate php include file within the inc folder. Figure 1. Expected output Requirement 1. You need to define the following constants in inc/config.inc.php • The number of students: 4 • The app developer: your name • The app ID: your student ID • The min score: 40 (to generate the random score) • The max score: 100 (to generate the random score) 2. Declare the following array in inc/config.inc.php • Assignment weights array with values: 0.3, 0.3, and 0.4 showHeader() calculateAndPrintData($weight) The student data is generated in generateRecord(). The first run of the app is notified here Displayed in two decimals The user does not want to continue. The number of times the app was run is displayed with a thank you message Can accept capital or lower case letter The weighted Total for each student is calculated. The feedback associated with the weighted total is looked up and displayed Your name and student ID displayed from the defined constant. Copyright © 2023 Bambang Sarif. Not for redistribution. Page 2 of 3 3. Create the following functions: • showHeader() – This will display the app header (see figures below) • generateRecord() – This will generate four students’ records. The function will generate a twodimensional data with the following structure. dataArray = [ student1_scores, student2_scores, student3_scores, student4_scores] Where each student_data is an array of three values that are generated randomly between the min and the max score using rand(MIN_SCORE, MAX_SCORE), for example, student1_scores = [rand(MIN_SCORE, MAX_SCORE), rand(MIN_SCORE, MAX_SCORE), rand(MIN_SCORE, MAX_SCORE)]. Note: you need to use a loop to generate the student_scores array. Hint: Think about creating an array of array using two loops. You can achieve this by starting with empty array, loops and array_push() to generate the record. This function will return the two dimension dataArray to the calling function. • calculateAndPrintData($weight) – This function will call generateRecord() to get the dataArray, calculate the weightedTotal of each student using function calculateWeightedScore($dataArray, $weight), get the feedback using function getFeedback($weightedTotal) and print out the output as shown in the accompanying figure. Since you need to get the weightedTotal and feedback for each student, you need to use a loop when displaying the data, call the functions and print out the result. Note that the student name is a generated as “Stu_X” with X denote the index. Note that the $weight that is passed to this function is the weight of each corresponding assesment as declared in the config.inc.php file. • calculateWeightedScore($studentScore, $weight) – This function is called within a loop in the calculateAndPrintData($weight) function. This function calulate the weighted Total is calculated as the sum of (score[0] * weight[0]) + (score[1] * weight[1]) + (score[2] * weight[2]) and return the weighted total to the calling function. Note: you MUST use loop(s) to calculate the weighted score value. The score is the student score, e.g., $dataArray[$i], with $i is the index of the student data array, and $weight is the weight of each corresponding assesment as declared in the config.inc.php file. • getFeedback($weightedTotal) – This function will return the feedback string for the associated $weightedTotal using the following rule. This function is called within a loop in the calculateAndPrintData($weight) function. The feedback is such that o If the weightedTotal is greater than or equal to 90, then the feedbak is “Excellent” o If the weightedTotal is greater than or equal to 75, then the feedbak is “Well Done” o If the weightedTotal is greater than or equal to 60, then the feedbak is “OK” o If the weightedTotal is greater than or equal to 50, then the feedbak is “Good Effort” o Otherwise the feedbak is “Needs Improvement” 4. Each run of the application will be notified by a counter (see the figures below) 5. After displaying the student record, the app will ask the user whether he/she wants to re-run the app again or not. If the user chose to re-run the app, the process will be repeated. Otherwise a thank you message will be displayed. Copyright © 2023 Bambang Sarif. Not for redistribution. Page 3 of 3 Simple Flowchart of the app LAB/ASSIGNMENT PRE-SUBMISSION CHECKLIST • Did you follow the naming convention for your files?! • Did you follow the naming convention for your folder?! • Does your submission work on another computer?! • Double check **before** submitting Copyright © 2023 Bambang A.B. Sarif and others. NOT FOR REDISTRIBUTION. STUDENTS FOUND REDISTRIBUTING COURSE MATERIAL IS IN VIOLATION OF ACAMEDIC INTEGRITY POLICIES AND WILL FACE DISCIPLINARY ACTION BY THE COLLEGE ADMINISTRATION Generate record for the number of students in $data: display student name and scores calculate weighted score get the feedback text showHeader() Rerun the app? Y or y N or n Make sure to validate the user input

Tags: , , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *