0% found this document useful (0 votes)
22 views

03 Laboratory Exercise 1

The program prompts the user to input 5 grades separated by newlines. It then converts the input to double values, calculates the total, average, and rounded average. The program outputs the average, rounded average, and whether the user passed or failed based on if the average is greater than or equal to 75.

Uploaded by

No Thanks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

03 Laboratory Exercise 1

The program prompts the user to input 5 grades separated by newlines. It then converts the input to double values, calculates the total, average, and rounded average. The program outputs the average, rounded average, and whether the user passed or failed based on if the average is greater than or equal to 75.

Uploaded by

No Thanks
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

using System;

public class HelloWorld

public static void Main(string[] args)

string userInput;

Console.WriteLine("Enter 5 grades separated by new line: ");

userInput = Console.ReadLine();

double g1 = Convert.ToDouble(userInput);

userInput = Console.ReadLine();

double g2 = Convert.ToDouble(userInput);

userInput = Console.ReadLine();

double g3 = Convert.ToDouble(userInput);

userInput = Console.ReadLine();

double g4 = Convert.ToDouble(userInput);

userInput = Console.ReadLine();

double g5 = Convert.ToDouble(userInput);

double total = g1+g2+g3+g4+g5;

double average = total/5;

double round = Math.Round(average);

Console.WriteLine("The average is "+average+" and round off to "+ round);

if(average >= 75){

Console.WriteLine("You passed!");

}else{

Console.WriteLine("You failed.");

You might also like