Assignment3C: I just didn’t wanna take it! We have a very forgiving exam policy. If you miss Test 1, Test 2 or Test 3 for any reason (receiving a 0), that exam will be replaced by whatever grade you get on the final (which is comprehensive). Of course, that’s a risky move (it’s better to take the exams than rely on the final), but it helps students when "life gets in the way." The final exam also replaces your lowest test grade if the final exam is higher and you took all the tests. Once the replacements have occurred, the overall score is calculated by taking the average of the quiz average, Test 1, Test 2, Test 3 and the Final Exam. The Final Exam does not replace the quiz average if it is lower. For simplicity, the final result should be rounded to the closest integer. For this assignment, you’ll ask the user for a quiz average and grades for Test 1, Test 2, Test 3 and the Final Exam. The program will output the overall numeric average according to the policy described above. Hint: determine if all tests have been taken, and only replace the lowest grade if that is true. Finish by replacing zeroes with the final exam grade. Call the class Assignment3C, and put in a file called Assignment3C (.java, .cs or .cpp).

Respuesta :

Answer: Provided in the explanation section

Explanation:

Source Code:

using System;

//class Assignment3C

class Assignment3C {

 

//main function

static void Main() {

//getting userinputs

Console.WriteLine("Quiz Average:");

int quizAverage = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Test 1:");

int test1 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Test 2:");

int test2 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Test 3:");

int test3 = Convert.ToInt32(Console.ReadLine());

Console.WriteLine("Final Test:");

int finalTest = Convert.ToInt32(Console.ReadLine());

 

//cehcking whether the score is equal to 0 ; if so relpace it with the final score

if(test1 == 0 || test2 == 0 || test3 ==0){

if(test1 == 0){

test1 = finalTest;

Console.WriteLine("Zero from Test 1 is replaced with a "+finalTest);

}

if(test2 == 0 ){

test2 = finalTest;

Console.WriteLine("Zero from Test 2 is replaced with a "+finalTest);

}

if(test3 == 0){

test3 = finalTest;

Console.WriteLine("Zero from Test 3 is replaced with a "+finalTest);

}

}

else

{

//Assume test 1 is minimum sccore

int min = test1;

if(test2 < min){

min = test2;

}

if(test3 < min){

min = test3;

}

 

// Replace the minimum test scores by finalTest score

if(test1 == min)

  {

  test1 = finalTest;

      Console.WriteLine("Final Test replaces Test 1");

  }

  if(test2 == min)

  {

  test2 = finalTest;

      Console.WriteLine("Final Test replaces Test 2");

  }

  if(test3 == min)

  {

  test3 = finalTest;

      Console.WriteLine("Final Test replaces Test 3");

  }

}

 

//calculating average score

int average = (quizAverage + test1 + test2 + test3) / 4;

Console.WriteLine("Overall grade is a "+average);

}

}