Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Looking for error on program. Any help would be great.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace DoprBox08

{

  class CollegeStudent

  {


    private string studentName;

    private int midTerm1;

    private int midTerm2;

    private int finalExam;


    public string StudenName

    {

      get { return studentName; }

      set { studentName = value; }

    }

    public int MidTerm1

    {

      get { return midTerm1; }

      set { midTerm1 = value; }

    }

    public int MidTerm2

    {

      get { return midTerm2; }

      set { midTerm1 = value; }

    }

    public int FinalExam

    {

      get { return finalExam; }

      set { finalExam = value; }

    }


    public object StudentName { get; private set; }


    public CollegeStudent(string studentName, int midTerm1, int midTerm2, int finalExam)

    {

      this.studentName = studentName;

      this.midTerm1 = midTerm1;

      this.midTerm2 = midTerm2;

      this.finalExam = finalExam;

    }

    public double SemesterGrade()

    {

      double grade;

      grade = 0.3 * MidTerm1 + 0.3 * MidTerm2 + 0.4 * FinalExam;

      return grade;

    }

    public override string ToString()

    {

      string str;

      str = string.Format(" Student name: {0} \nSemester grade: {1}", StudentName, SemesterGrade());

      return str;

    }

  }

}

Answers

  • What is the error you are getting??

  • No error anymore just not able to get the "Student Name" to populate when running program. The code allows the program to calculate the scores appropriately but just cannot get the name that is entered to populate with the calculated scores. Using C# in Vis Studio Comm. 2019 edition. Console APP (.Net Framework

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Threading.Tasks;


    namespace DoprBox08

    {

      class CollegeStudent

      {

      public static void Main(string[] args)

        {

          Console.Title = ("College Student ");

          Console.WriteLine("Please enter your name: \nand the three scores: ");

          string name = Console.ReadLine();

          int midTerm1 = int.Parse(Console.ReadLine());

          int midTerm2 = int.Parse(Console.ReadLine());

          int finalExam = int.Parse(Console.ReadLine());

          CollegeStudent student = new CollegeStudent(name, midTerm1, midTerm2, finalExam); //Invoking the constructor


          Console.WriteLine(student); //invokes ToString()

          Console.ReadKey();

        }

        public override string ToString()

        {

          string str;

          str = string.Format(" Student name: {0} \nSemester grade: {1}", StudentName, SemesterGrade());

          Console.WriteLine();

          return str;

        }

        private string studentName;

        private int midTerm1;

        private int midTerm2;

        private int finalExam;

        public string StudenName

        {

          get { return studentName; }

          set { studentName = value; }

        }

        public int MidTerm1

        {

          get { return midTerm1; }

          set { midTerm1 = value; }

        }

        public int MidTerm2

        {

          get { return midTerm2; }

          set { midTerm1 = value; }

        }

        public int FinalExam

        {

          get { return finalExam; }

          set { finalExam = value; }

        }


        public object StudentName { get; private set; }


        public CollegeStudent(string studentName, int midTerm1, int midTerm2, int finalExam)

        {

          this.studentName = studentName;

          this.midTerm1 = midTerm1;

          this.midTerm2 = midTerm2;

          this.finalExam = finalExam;

        }

        public double SemesterGrade()

        {

          double grade;

          grade = 0.3 * MidTerm1 + 0.3 * MidTerm2 + 0.4 * FinalExam;

          return grade;

        }


      }

    }

Sign In or Register to comment.