COMPUTE GRADE PROGRAM
Create a function named StudeInfo that will accept the following values from the user:
StudentID, StudentName, Course, Age, PrelimGrade, MidtermGrade, FinalTermGrade.
Create a function named ComputeGrade that will compute Final Average which is computed as the sum of PrelimGrade, MidtermGrade and FinalTermGrade divided by 3.
Display the output with the following format: (sample output)
*************************************************************************************
Student ID : 00-00-01
Student Name : FERNAN W. AMMAQUI
____________________________________________________________________________________
PRELIM GRADE : 90.0
MIDTERM GRADE : 90.0
FINAL GRADE : 90.0
AVERAGE : 90.0
*************************************************************************************
Color the Student ID and Name values with green. Failing average will be colored with red. Otherwise, color it with blue.
using System;
namespace MathApp
{
class Program
{
public static void StudeInfo(string StudentID, string StudentName, int Course, int Age,
double PrelimGrade, double MidtermGrade, double FinalTermGrade )
{
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine($"Student ID: {StudentID}\n" +
$"Student Name: {StudentName}\n" +
$"Course: {Course}\n" +
$"Age: {Age}");
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine($"Prelim Grade: {PrelimGrade}\n" +
$"Midterm Grade: {MidtermGrade}\n" +
$"Final Term Grade: {FinalTermGrade}\n");
}
public static void ComputeGrade(double PrelimGrade, double MidtermGrade, double FinalTermGrade)
{
double average = (PrelimGrade + MidtermGrade + FinalTermGrade) / 3;
if (average >= 60)
Console.ForegroundColor = ConsoleColor.Blue;
else
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"Average: {average}");
Console.ForegroundColor = ConsoleColor.Green;
}
static void Main(string[] args)
{
StudeInfo("00-00-01", "FERNAN W. AMMAQUI", 2, 20, 90.0, 90.0, 90.0);
ComputeGrade(90.0, 90.0, 90.0);
StudeInfo("00-00-02", "FERNAN W. EDGEN", 2, 21, 59.0, 59.0, 59.0);
ComputeGrade(59.0, 59.0, 59.0);
}
}
}
Comments
Leave a comment