Question

ASSIGNMENT #3 ** using System; namespace GradeCalculatorNew {    class MainClass    {        public...

ASSIGNMENT #3 **

using System;

namespace GradeCalculatorNew
{
   class MainClass
   {
       public static void Main (string[] args)
       {
           int test1,test2,test3;
           double average,average2;
           char letterGrade;
           Console.WriteLine("Enter test score1");
           test1=Convert.ToInt32(Console.ReadLine());
           Console.WriteLine("Enter test score2");
           test2=Convert.ToInt32(Console.ReadLine());
           Console.WriteLine("Enter test score3");
           test3=Convert.ToInt32(Console.ReadLine());
           average=(test1+test2+test3)/3.0;
           average=(int)(average+0.5);
           if(average>=90)
           letterGrade='A';
           else if(average>=70)
           {
               if(test3>=90)
               letterGrade='A';
               else
               letterGrade='B';
           }
           else if(average>=50)
           {
               average2=(test2+test3)/2.0;
               average2=(int)(average2+0.5);
               if(average2>=70)
               letterGrade='C';
               else
               letterGrade='D';
           }
           else
               letterGrade='F';
           Console.WriteLine("Grade of Student is {0}",letterGrade);

Lab Assignment 5

This assignment is based on Assignment 3 and rewrite it using multiple methods to calculate the student average and letter grade. The followings are the rules of calculating the average and letter grade. Average Score Calculation: Average Score = (Test Score 1 + Test Score 2 + Test Scores 3) /3 Grade Conversion Rules: rule a. If the average score is 90 or more the grade is 'A'. rule b. If the average score is 70 or more and less than 90 then check the third test score. If the third score is 90 or more the grade is 'A' otherwise the grade is 'B'. rule c. If the average score is 50 or more and less than 70 then check the average of the second and third scores. If the average of the last two is 70 or more, the grade is 'C' otherwise it is a 'D' rule d. If the average score is less than 50 then the grade is 'F'. Rounding Rule: Midpoint Rounding Calculate the grade average as a double. Round up to the next int if the fractional part is .5 or greater, otherwise truncate the fraction by casting to an int. The algorithm is: Add .5 to the average and cast the result to an int. Methods required in the project: GradesInput() – Get 3 test scores from the user and pass back 3 test scores to the calling method. Average3Scores() – Average three test scores and apply the rounding rule and return the average. AverageLast2Scores() – Average last 2 test scores and apply the rounding rule and return the average. ToLetterGrade() – Convert average grade to letter grade according the grade conversion rules and return the letter grade. DisplayGrade() – Display both average grade and letter grade, and do not return anything. Create a new project in Visual Studio, name it FirstName_LastName_A5 where FirstName is your first name and LastName is your last name. Submit your zipped project folder in Eagle online. 1/16/2017 COSC 1436 Programming Fundamentals I C# Program Design This assignment is using method to reorganize your code. You can take assignment 3 that you have completed as the base code and add the methods below and call all the methods inside of your main() method. Each of the method will replace the code in your main() method that you wrote in assignment 3. After all the methods have been called, your main() will be very short and organized. Here are the layout for each method static void GradesInput(out int s1, out int s2, out int s3) { //Prompt user to enter the first test score //Read the test score and store it into s1 //Validate the test input to make sure it is between 0 and 100 //Prompt user to enter the second test score //Read the test score and store it into s2 //Validate the test input to make sure it is between 0 and 100 //Prompt user to enter the third test score //Read the test score and store it into s3 //Validate the test input to make sure it is between 0 and 100 } static double average3Scores(int s1, int s2, int s3) { //Declare a double variable to hold average //Calculate average by adding three scores (s1, s2, and s3) and divided it by 3.0 //Apply rounding rule //return average } static double average2Scores(int s2, int s3) { //Declare a double variable to hold average of 2 test scores //Calculate average by adding two test scores (s2 and s3) and divided it by 2.0 //Apply rounding rule //return average } static char toLetterGrade(double avg, double avg2 ,int s3) { //Declare a letter grade variable //Apply grade conversion rule using if.. else if statement //return letter grade } static void displayGrade(double avg, char lGrade) { //Display average of 3 test scores (avg) //Display letter grade (lGrade)

0 0
Add a comment Improve this question Transcribed image text
Answer #1
Complete C# Program

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FirstName_LastName_A5
{
    class Program
    {
        static void Main(string[] args)
        {
            int test1, test2, test3;
            GradesInput(out test1, out test2, out test3);
            int average = average3Scores(test1, test2, test3);
            int average2 = AverageLast2Scores(test2, test3);
            char letterGrade = ToLetterGrade(average, average2, test3);
            Console.WriteLine();
            displayGrade(average, letterGrade);
            Console.ReadKey();
        }

        static void GradesInput(out int s1, out int s2, out int s3)
        {
            Console.WriteLine("Enter test score1");
            s1 = Convert.ToInt32(Console.ReadLine());
            if (s1 < 0 || s1 > 100)
            {
                Console.WriteLine("Score must be in range 0 to 100");
                Environment.Exit(-1);
            }
            Console.WriteLine("Enter test score2");
            s2 = Convert.ToInt32(Console.ReadLine());
            if (s2 < 0 || s2 > 100)
            {
                Console.WriteLine("Score must be in range 0 to 100");
                Environment.Exit(-1);
            }
            Console.WriteLine("Enter test score3");
            s3 = Convert.ToInt32(Console.ReadLine());
            if (s3 < 0 || s3 > 100)
            {
                Console.WriteLine("Score must be in range 0 to 100");
                Environment.Exit(-1);
            }
        }

        static int average3Scores(int test1, int test2, int test3)
        {
            double average = (test1 + test2 + test3) / 3.0;
            return (int)(average + 0.5);
        }

        static int AverageLast2Scores(int test2, int test3)
        {
            double average = (test2 + test3) / 2.0;
            return (int)(average + 0.5);
        }

        static char ToLetterGrade(int average, int average2, int test3)
        {
            char letterGrade = ' ';
            if (average >= 90)
                letterGrade = 'A';
            else if (average >= 70)
            {
                if (test3 >= 90)
                    letterGrade = 'A';
                else
                    letterGrade = 'B';
            }
            else if (average >= 50)
            {
                if (average2 >= 70)
                    letterGrade = 'C';
                else
                    letterGrade = 'D';
            }
            else
                letterGrade = 'F';
            return letterGrade;
        }


        static void displayGrade(double avg, char lGrade)
        {
            Console.WriteLine("Average grade of the student is {0}", avg);
            Console.WriteLine("Letter grade of the Student is {0}", lGrade);
        }

    }
}

OUTPUT

Add a comment
Know the answer?
Add Answer to:
ASSIGNMENT #3 ** using System; namespace GradeCalculatorNew {    class MainClass    {        public...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Test Scores and Grade Write a program that has variables to hold three test scores. The...

    Test Scores and Grade Write a program that has variables to hold three test scores. The program should ask the user to enter three test scores and then assign the values entered to the variables. The program should display the average of the test scores and the letter grade that is assigned for the test score average. Use the grading scheme in the following table: Test Score Average Letter Grade 90–100 A 80–89 B 70–79 C 60–69 D Below 60...

  • This C# program prints out a corresponding letter grade for a given mark. It uses a...

    This C# program prints out a corresponding letter grade for a given mark. It uses a method (called MarktoGrade) to determine the letter grade. MarktoGrade takes one integer call by value formal parameter (called mark) and returns a char value that is the letter grade. All of the input and output (except an error message) is done in Main. There is one syntax error in this program that you will need to fix before it will compile (the error is...

  • i need help fixing my code. here is the assignment: Make a class that contains the...

    i need help fixing my code. here is the assignment: Make a class that contains the following functions: isLong, isDouble, stringToLong, and stringToDouble. Each receives a string and returns the appropriate type (bool, bool, long, and double).During the rest of the semester you will paste this class into your programs and will no longer use any of the "standard" c# functions to convert strings to numbers. here is my code. it works for the long method but not the double:...

  • This is my code for a final GPA calculator. For this assignment, I'm not supposed to...

    This is my code for a final GPA calculator. For this assignment, I'm not supposed to use global variables. My question is: does my code contain a global variable/ global function, and if so how can I re-write it to not contain one? /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Title: Final GPA Calculator * Course Computational Problem Solving CPET-121 * Developer: Elliot Tindall * Date: Feb 3, 2020 * Description: This code takes grades that are input by the student and displays * their...

  • Hello, Can you please error check my javascript? It should do the following: Write a program...

    Hello, Can you please error check my javascript? It should do the following: Write a program that uses a class for storing student data. Build the class using the given information. The data should include the student’s ID number; grades on exams 1, 2, and 3; and average grade. Use appropriate assessor and mutator methods for the grades (new grades should be passed as parameters). Use a mutator method for changing the student ID. Use another method to calculate the...

  • import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {   ...

    import java.util.Scanner; public class StudentClient {       public static void main(String[] args)    {        Student s1 = new Student();         Student s2 = new Student("Smith", "123-45-6789", 3.2);         Student s3 = new Student("Jones", "987-65-4321", 3.7);         System.out.println("The name of student #1 is ");         System.out.println("The social security number of student #1 is " + s1.toString());         System.out.println("Student #2 is " + s2);         System.out.println("the name of student #3 is " + s3.getName());         System.out.println("The social security number...

  • Professor Dolittle has asked some computer science students to write a program that will help him...

    Professor Dolittle has asked some computer science students to write a program that will help him calculate his final grades. Professor Dolittle gives two midterms and a final exam. Each of these is worth 100 points. In addition, he gives a number of homework assignments during the semester. Each homework assignment is worth 100 points. At the end of the semester, Professor Dolittle wants to calculate the median score on the homework assignments for the semester. He believes that the...

  • Modify Assignment #18 so it drops each student’s lowest score when determining the students’ test score...

    Modify Assignment #18 so it drops each student’s lowest score when determining the students’ test score average and Letter grade. No scores less than 0 or greater than 100 should be accepted #include<iostream> #include<string> using namespace std; int main() { double average[5]; string name[5]; char grade[5]; for(int i=0; i<=5; i++) { cout<<"Enter student name: "; cin.ignore(); getline(cin,name[i]); int sum=0; for(int j=0; j<5; j++) { int grades; cout<<"Enter Grades:"<<j+1<<" : "; cin>>grades; sum+=grades; } average[i]=(float)sum/5; if(average[i]>=90 && average[i]<=100) grade[i]='A'; else if(average[i]>=80...

  • C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to...

    C++ Assignment on Search and Sort for Chapter 8 Problem: Modify the student grade problem to include the following: •   Write a Search function to search by student score •   Write a Search function to search by student last name •   Write a Sort function to sort the list by student score •   Write a Sort function to sort the list by student last name •   Write a menu function that lets user to choose any action he/she want to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT