{"id":101654,"date":"2022-10-28T03:53:39","date_gmt":"2022-10-28T03:53:39","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/cmis-102-hands-on-lab-week-5\/"},"modified":"2022-10-28T03:53:39","modified_gmt":"2022-10-28T03:53:39","slug":"cmis-102-hands-on-lab-week-5","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/cmis-102-hands-on-lab-week-5\/","title":{"rendered":"Cmis 102 hands-on lab week 5"},"content":{"rendered":"<div>\n<p>\u00a0<\/p>\n<p>CMIS 102 Hands-On Lab<\/p>\n<p>\/\/ Week 5<\/p>\n<p><strong>Overview:<\/strong><br \/>This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, design (using pseudocode visualization), and implementation with C code.\u00a0 The example provided uses sequential, repetition statements and nested repetition statements.<\/p>\n<p><strong>Program Description:<\/strong><\/p>\n<p>This program will calculate the average of 3 exams for 5 students. The program will ask the user to enter 5 student names. For each of the students, the program will ask for 3 exam scores. \u00a0The average exam score for each student will be calculated and printed.<\/p>\n<p><strong>Analysis:<\/strong><\/p>\n<p>I will use sequential and repetition programming statements.<br \/>I will define one String to store student name: StudentName.<br \/>I will define three Float numbers: Examvalue, Sum, Avg to store exam values the sum of the exams and the average of the exams.<br \/>The sum will be calculated by this formula:<br \/>\u00a0Sum = Sum + Examvalue<br \/>For example, if the first value entered was 80.0 and second was 90.0 and the third exam was 100.0:<br \/>sum = sum + Examvalue = 0.0 + 80.0<br \/>sum = 80.0 + 90.0 = 170.0<br \/>sum = 170.0 + 100.0 = 270.0<br \/>Avg is then calculated as:<br \/>Avg = sum\/3.0<br \/>For example 270.0\/3.0 = 90.0<br \/>A nested repetition loop can be used to loop through each of the 5 students and each of the 3 exams:<br \/>For (students=0; students &lt;5; students++)<br \/>\u00a0\u00a0\u00a0 For (exams=0;exams&lt;3;exams++)<br \/>\u00a0\u00a0 End For<br \/>End For<br \/>Sum values will need to be reset for each student to ensure only one student data is used for calculations each time.<br \/>\u00a0<\/p>\n<p><strong>Test Plan:<\/strong><\/p>\n<p>To verify this program is working properly the input values could be used for testing:<\/p>\n<p>Test Case<\/p>\n<p>Input<\/p>\n<p>Expected Output<\/p>\n<p>1<\/p>\n<p>Studentname=Chris<br \/>Examvalue1=80.0<br \/>Examvalue2=90.0<br \/>Examvalue3=100.0<br \/>Studentname=John<br \/>Examvalue1=70.0<br \/>Examvalue2=90.0<br \/>Examvalue3=80.0<br \/>Studentname=Sally<br \/>Examvalue1=100.0<br \/>Examvalue2=100.0<br \/>Examvalue3=100.0<br \/>Studentname=Pat<br \/>Examvalue1=50.0<br \/>Eexamvalue2=70.0<br \/>Examvalue3=60.0<\/p>\n<p>Studentname=Sam<br \/>Examvalue1=90.0<br \/>Examvalue2=95.0<br \/>Examvalue3=100.0<br \/>\u00a0<\/p>\n<p>Average for Chris is 90.0<br \/>Average for John is 80.0<br \/>Average for Sally is 100.0<\/p>\n<p>Average for Pat is 60.0<br \/>Average for Sam is 95.0<\/p>\n<p><strong>Pseudocode:<\/strong><\/p>\n<p>\/\/ This program will calculate the average of 3 exams for 5 students<\/p>\n<p>\/\/ Declare variables<br \/>Declare StudentName as String<br \/>Declare ExamValue, Sum, Avg as Float<\/p>\n<p>\/\/ Loop through 5 Students<br \/>For (students=0; students &lt;5 ; students++)<br \/>\u00a0\u00a0 \/\/ reset Sum to 0<br \/>\u00a0 Set Sum =0.0\u00a0<br \/>\u00a0\u00a0 Print \u201cEnter Student Name\u201d<br \/>\u00a0\u00a0 Input StudentName<br \/>\u00a0\u00a0 \/\/ Nested Loop for Exams<br \/>\u00a0 For (exams=0; exams &lt; 3; exams++)<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 Print \u201cEnter exam grade: n\u201d<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 Input ExamValue<br \/>\u00a0\u00a0\u00a0\u00a0\u00a0 Set Sum = Sum + ExamValue<br \/>\u00a0\u00a0 End For<br \/>\u00a0\u00a0\u00a0 Set Avg = Sum\/3.0<br \/>\u00a0\u00a0 Print \u201cAverage for \u201c + StudentName + \u201c is \u201c + Avg<br \/>\u00a0End For<br \/>\u00a0<\/p>\n<p><strong>Flow Chart:<\/strong><\/p>\n<p><strong>C Code<\/strong><\/p>\n<p>The following is the C Code that will compile in execute in the online compilers.<\/p>\n<p>\/\/ C code<\/p>\n<p>\/\/ This program will calculate the average of 3 exams for 5 students.<\/p>\n<p>\/\/ Developer: Faculty CMIS102<\/p>\n<p>\/\/ Date: Jan 31, 2014<\/p>\n<p>#include &lt;stdio.h&gt;<\/p>\n<p>int main ()<\/p>\n<p>{<\/p>\n<p>\u00a0 \/* variable definition: *\/<\/p>\n<p>\u00a0 char StudentName[100];<\/p>\n<p>\u00a0 float ExamValue, Sum, Avg;<\/p>\n<p>\u00a0 int students,exams;<\/p>\n<p>\u00a0\u00a0 \/\/ Loop through 5 Students<\/p>\n<p>\u00a0 for (students=0; students &lt;5 ; students++)<\/p>\n<p>\u00a0 {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0 \/\/ reset Sum to 0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0 Sum =0.0;\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0 printf(&#8220;Enter Student Name n&#8221;);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0 scanf(&#8220;%s&#8221;, StudentName);\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0 \/\/ Nested Loop for Exams<\/p>\n<p>\u00a0\u00a0\u00a0 for (exams=0; exams &lt; 3; exams++)<\/p>\n<p>\u00a0\u00a0\u00a0 {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 printf (&#8220;Enter exam grade: n&#8221;);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 scanf(&#8220;%f&#8221;, &amp;ExamValue);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Sum = Sum + ExamValue;<\/p>\n<p>\u00a0\u00a0\u00a0 }\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0 Avg = Sum\/3.0;<\/p>\n<p>\u00a0\u00a0\u00a0 printf( &#8220;Average for %s is %fn&#8221;,StudentName,Avg);<\/p>\n<p>\u00a0 }<\/p>\n<p>\u00a0 return 0;<\/p>\n<p>}<\/p>\n<p>Setting up the code and the input parameters in ideone.com:<\/p>\n<p>Note the Student and ExamValues for this run were:<br \/>John: 90.0 80.0 100.0<br \/>Jim: 80.0 70.0 90.0<br \/>Joe: 70.0 100.0 100.0<br \/>Sally: 100.0 95.0 91.0<br \/>Sam: 30.0 54.0 68.0<br \/>You can change these values to any valid integer values to match your test cases.<\/p>\n<p>Results from running the programming at ideone.com:<\/p>\n<p><strong>Learning Exercises for you to try:<\/strong><\/p>\n<ol>\n<li>What would you change in the design and the code if you wanted to input 10 students and 5 exams?<\/li>\n<li>What is the line of code doing?<\/li>\n<\/ol>\n<p>\u00a0 \u00a0\u00a0\u00a0 char StudentName[100];<\/p>\n<p>(Hint: We haven\u2019t covered arrays, but a String can be thought of as an array of characters) ?<\/p>\n<ol>\n<li>What would happen if you moved the Set Sum = 0.0 from inside the for loop to right after the declaration. For example:<\/li>\n<\/ol>\n<p>\/\/ Declare variables<br \/>Declare StudentName as String<br \/>Declare ExamValue, Sum, Avg as Float<\/p>\n<p>\/\/ Initialize Sum<br \/>Set Sum = 0.0;<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 CMIS 102 Hands-On Lab \/\/ Week 5 Overview:This hands-on lab allows you to follow and experiment with the critical steps of developing a program including the program description, analysis, test plan, design (using pseudocode visualization), and implementation with C code.\u00a0 The example provided uses sequential, repetition statements and nested repetition statements. Program Description: This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-101654","post","type-post","status-publish","format-standard","hentry","category-education"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/101654","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=101654"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/101654\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=101654"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=101654"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=101654"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}