2
Answers

loop problem,PLEASE HELP!!!!!!!!

maria

maria

16y
1.9k
1
i am very new to programming.i am stuck on adding a for loop to my program.this is the requirements:Design and write a program to read names and exam marks of 8 students and output names and equivalent exam grades in each case. Grades are to be worked out as follows: if the mark is <40 then grade is a FAIL; for a mark in the range 40-59, the grade is PASS; if the mark is 60-79 then it is MERIT and for a mark >=80 the grade is DISTINCTION. Your program should accept a numeric value in the range 0-100. For any other value, the program should display an error message and terminate. Use a switch statement for selection and a for loop for repetition. This is what  i have so far after the Main method:
{
            int marks;
            string name;

            Console.WriteLine("Enter name");
            name = Console.ReadLine();
            Console.WriteLine("Enter marks");
            marks = int.Parse(Console.ReadLine());

            if (marks < 40)
            {
                Console.WriteLine("Fail");
            }
            else if (marks >= 40 && marks <= 59)
            {
                Console.WriteLine("Pass");
            }
            if (marks >=60 && marks <=79)
            {
                Console.WriteLine("Credit");
            }
            else if (marks >= 80 && marks <= 100)
            {

                Console.WriteLine("Distinction");
            }
            if(marks <0 || marks >100)
            {
                Console.WriteLine("Data error" );
            }
           
              

Answers (2)