Answer to Question #248819 in C# for Anino

Question #248819

q1) fill in the required code line where //*** insert code is

 const int PASS = 50;

    int numPass = 0, numFail = 0, totalMarks = 0;

    double mark, perPass = 0, perFail = 0;

  while (mark >= 0)

    {

      // increment the counter for the total number of data values

      // *** Insert code


      // Determine if the mark is a pass or fail (If statement)

      // *** Insert code


      // Read next mark

      // *** Insert code

    }


    // Calculate the percentage of marks that were passes and fails

    // *** Insert code


1
Expert's answer
2021-10-09T04:44:53-0400
using System;


namespace App
{
    class Program
    {
        


        static void Main(string[] args)
        {
            const int PASS = 50;
            int numPass = 0, numFail = 0, totalMarks = 0;
            double mark, perPass = 0, perFail = 0;


            // loop to read in a valid mark or the sentinel value
            do
            {
                // Read initial mark (seed the loop)
                Console.Write("Enter a mark between 0 and 100 (-ve value to stop): ");
                mark = Convert.ToDouble(Console.ReadLine());
            } while (mark > 100);
            // if the inputted mark is not the sentinel value, process it


            while (mark >= 0)
            {


                // increment the counter for the total number of data values
                totalMarks++; 


                // Determine if the mark is a pass or fail (If statement)
                if (mark >= PASS){
                    Console.WriteLine("You have Succesfully passed the class");
                    numPass++;
                }
                else {
                    Console.WriteLine("You have Failed the class");
                    numFail++;
                }


                    




                // Read next mark
                Console.Write("Enter a mark between 0 and 100 (-ve value to stop): ");
                mark = Convert.ToDouble(Console.ReadLine());
            }


            // Calculate the percentage of marks that were passes and fails
            perPass = (double)numPass / (double)totalMarks;
            perFail = (double)numFail / (double)totalMarks;


            // Print results
            Console.WriteLine("Total number of marks = {0}", totalMarks);
            Console.WriteLine("Percentage of passing marks = {0:p1}", perPass);
            Console.WriteLine("Percentage of failing marks = {0:p1}", perFail);




            Console.ReadLine();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS