CMIS 102 Hands-On Lab

// Week 5

Overview:
This hands-on lab allows you to prosper and ordeal with the fastidious steps of developing a program including the program contemplationation, dissection, ordeal cunning, contemplation (using pseudojurisdiction visualization), and implementation with C jurisdiction.  The development granted representations sequential, dwelling-upon statements and nested dwelling-upon statements.

Program Contemplationation:

This program procure consider the mediocre of 3 exams coercion 5 learners. The program procure implore the representationr to penetrate 5 learner names. Coercion each of the learners, the program procure implore coercion 3 exam jaws.  The mediocre exam jaw coercion each learner procure be considerd and printed.

Analysis:

I procure representation sequential and dwelling-upon programming statements.
I procure fix single String to treasury learner name: LearnerName.
I procure fix three Transport numbers: Examvalue, Incorporate, Avg to treasury exam esteems the incorporate of the exams and the mediocre of the exams.
The incorporate procure be considerd by this coercionmula:
 Incorporate = Incorporate + Examvalue
Coercion development, if the chief esteem penetrateed was 80.0 and remedy was 90.0 and the third exam was 100.0:
incorporate = incorporate + Examesteem = 0.0 + 80.0
incorporate = 80.0 + 90.0 = 170.0
incorporate = 170.0 + 100.0 = 270.0
Avg is then considerd as:
Avg = incorporate/3.0
Coercion development 270.0/3.0 = 90.0
A nested dwelling-upon loop can be representationd to loop through each of the 5 learners and each of the 3 exams:
Coercion (students=0; learners <5; learners++)
    Coercion (exams=0;exams<3;exams++)
   End Coercion
End Coercion
Incorporate esteems procure need to be reset coercion each learner to fix singly single learner facts is representationd coercion calculations each spell.
 

Ordeal Cunning:

To demonstrate this program is atransport just the input esteems could be representationd coercion ordealing:

Ordeal Case

Input

Expected Output

1

Studentname=Chris
Examvalue1=80.0
Examvalue2=90.0
Examvalue3=100.0
Studentname=John
Examvalue1=70.0
Examvalue2=90.0
Examvalue3=80.0
Studentname=Sally
Examvalue1=100.0
Examvalue2=100.0
Examvalue3=100.0
Studentname=Pat
Examvalue1=50.0
Eexamvalue2=70.0
Examvalue3=60.0

Studentname=Sam
Examvalue1=90.0
Examvalue2=95.0
Examvalue3=100.0
 

Mediocre coercion Chris is 90.0
Mediocre coercion John is 80.0
Mediocre coercion Sally is 100.0

Mediocre coercion Pat is 60.0
Mediocre coercion Sam is 95.0

Pseudocode:

// This program procure consider the mediocre of 3 exams coercion 5 learners

// Declare waverings
Declare LearnerName as String
Declare ExamValue, Incorporate, Avg as Transport

// Loop through 5 Learners
Coercion (students=0; learners <5 ; learners++)
   // reset Incorporate to 0
  Set Incorporate =0.0 
   Print “Penetrate Learner Name”
   Input LearnerName
   // Nested Loop coercion Exams
  Coercion (exams=0; exams < 3; exams++)
      Print “Penetrate exam grade: n”
      Input ExamValue
      Set Incorporate = Incorporate + ExamValue
   End Coercion
    Set Avg = Incorporate/3.0
   Print “Mediocre coercion “ + LearnerName + “ is “ + Avg
 End Coercion
 

Flow Chart:

C Jurisdiction

The prospering is the C Jurisdiction that procure put-together in consummate in the oncourse put-togetherrs.

// C jurisdiction

// This program procure consider the mediocre of 3 exams coercion 5 learners.

// Developer: Faculty CMIS102

// Date: Jan 31, 2014

#include <stdio.h>

int ocean ()

{

  /* wavering definition: */

  char LearnerName[100];

  transport ExamValue, Incorporate, Avg;

  int learners,exams;

   // Loop through 5 Learners

  coercion (students=0; learners <5 ; learners++)

  {

     // reset Incorporate to 0

     Incorporate =0.0; 

     printf(“Penetrate Learner Name n”);

     scanf(“%s”, LearnerName);  

     // Nested Loop coercion Exams

    coercion (exams=0; exams < 3; exams++)

    {

        printf (“Penetrate exam grade: n”);

        scanf(“%f”, &ExamValue);

        Incorporate = Incorporate + ExamValue;

    }  

    Avg = Incorporate/3.0;

    printf( “Mediocre coercion %s is %fn”,StudentName,Avg);

  }

  repay 0;

}

Setting up the jurisdiction and the input parameters in ideone.com:

Note the Learner and ExamValues coercion this retreat were:
John: 90.0 80.0 100.0
Jim: 80.0 70.0 90.0
Joe: 70.0 100.0 100.0
Sally: 100.0 95.0 91.0
Sam: 30.0 54.0 68.0
You can modify these esteems to any substantial integer esteems to equality your ordeal cases.

Results from retreatning the programming at ideone.com:

Learning Exercises coercion you to try:

  1. What would you modify in the contemplation and the jurisdiction if you wanted to input 10 learners and 5 exams?
  2. What is the course of jurisdiction doing?

      char LearnerName[100];

(Hint: We haven’t familiar marshals, notwithstanding a String can be cogitation of as an marshal of characters) ?

  1. What would supervene if you moved the Set Incorporate = 0.0 from within the coercion loop to just following the ordinance. Coercion development:

// Declare waverings
Declare LearnerName as String
Declare ExamValue, Incorporate, Avg as Transport

// Initialize Incorporate
Set Incorporate = 0.0;

~~~For this or similar assignment papers~~~