EngE_1114_HW10

EngE_1114_HW10 - 1) Given: grades Required: Flowchart,...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 1) Given: grades Required: Flowchart, MatLab code, and sample run Relationships: Solution: % This function will return the number of grades inputted, the average of % those grades, and the standard deviation of those grades, when provided % with the number value of those grades. Call statement: grade_avg sum_grade=0; N=0; sum = 0; again=input( '\n Please enter a 1 if a grade is to be entered, 0 if there are no grades: ' ); while again~=0 N=N+1; grade(N)=input( '\n Please enter the grade: ' ); sum_grade = sum_grade + grade(N); again=input( '\n Please enter the 1 if a grade is to be entered, 0 if there are no grades: ' ); end if sum_grade == 0 fprintf ( 'Error. You did not enter any grades.\n' ) else avg = sum_grade/N; for z = 1:1:N l = (grade(z) - avg)^2; sum = sum + l; s = (sum./N)^(1/2); end fprintf ( '\nThere were %.0f grades entered. The average of those grades is %f. The' ,N,avg) fprintf ( ' standard deviation is %f.\n' ,s) end 12:20 M | EngE 1114 HW10 | 25 February, 2006 | Konzik, Kit | / >> grade_avg Please enter a 1 if a grade is to be entered, 0 if there are no grades: 1 Please enter the grade: 89 Please enter the 1 if a grade is to be entered, 0 if there are no grades: 1 Please enter the grade: 94 Please enter the 1 if a grade is to be entered, 0 if there are no grades:...
View Full Document

Page1 / 7

EngE_1114_HW10 - 1) Given: grades Required: Flowchart,...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online