Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.84 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace StudentTestScoreArray
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string numberStudents;
  14.             string tempValue;
  15.             int numStudents = 0;
  16.             int numTest = 0;
  17.             int testScore = 0;
  18.             int[] highScore;
  19.             int[] lowScore;
  20.             int[] scoreAverage;
  21.             int[] studentID;
  22.             StringBuilder finalString = new StringBuilder();
  23.  
  24.             Console.WriteLine("Enter in the number of students:");
  25.             numberStudents = Console.ReadLine();
  26.             numStudents = Convert.ToInt32(numberStudents);
  27.  
  28.             studentID = new int[numStudents];
  29.             scoreAverage = new int[numStudents];
  30.             highScore = new int[numStudents];
  31.             lowScore = new int[numStudents];
  32.  
  33.             for (int i = 0; i < numStudents - 1; i++)
  34.             {
  35.                 Console.WriteLine("Enter the student ID:");
  36.                 tempValue = Console.ReadLine();
  37.                 studentID[i] = Convert.ToInt32(tempValue);
  38.  
  39.                 Console.WriteLine("Enter the number of test: ");
  40.                 tempValue = Console.ReadLine();
  41.                 numTest = Convert.ToInt32(tempValue);
  42.  
  43.                 for (int j = 0; j < numTest -1; j++)
  44.                 {
  45.                     Console.WriteLine("Enter the test score:");
  46.                     tempValue = Console.ReadLine();
  47.                     testScore = Convert.ToInt32(tempValue) + testScore;
  48.                     if (j == 0)
  49.                     {
  50.                         highScore[i] = testScore;
  51.                         lowScore[i] = testScore;
  52.                     }
  53.                     else
  54.                     {
  55.                         if (highScore[i] < testScore)
  56.                             highScore[i] = testScore;
  57.  
  58.                         if (lowScore[i] > testScore)
  59.                             lowScore[i] = testScore;
  60.                     }
  61.                 }
  62.                 scoreAverage[i] = testScore / numTest;
  63.             }
  64.  
  65.             for (int i = 0; i < studentID.Length; i++)
  66.             {
  67.                 finalString.Append("Student ID: ");
  68.                 finalString.Append(studentID[i]);
  69.                 finalString.AppendLine();
  70.  
  71.                 finalString.Append("Average Test score:");
  72.                 finalString.Append(scoreAverage[i]);
  73.                 finalString.AppendLine();
  74.  
  75.                 finalString.Append("Highest Score:");
  76.                 finalString.Append(highScore[i]);
  77.                 finalString.AppendLine();
  78.  
  79.                 finalString.Append("Lowest Score:");
  80.                 finalString.Append(lowScore[i]);
  81.                 finalString.AppendLine;
  82.             }
  83.         }
  84.  
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement