Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!,
I am editing a code for a project and Im stuck at creating a instance! I need to create an instance that

1. Create three instances of the student class, all with different student ids
2. Set the first name, last name, and middle initial for each of the three student objects
3. Enroll the first two student objects in "CIS 252"
4. Write the full name of each student object and whether those students are enrolled to the console window
5. Add a grade to each of the three students with a total possible points of 100 and earned points of 50, 85, and 98
6. Write the full name of each student object and the course letter grade for each student


I have no idea where to even start in the Program.cs class! Im hoping someone can even point me in the right direction to what to do! Thank You in Advance!

Now this is my code for the Student_.cs class

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

 namespace Test1_Student_Enroll
{
    public class Student_
    {
        public string Studentid
        {
            get
        {
            throw new System.NotImplementedException();
        }
        set
        {
        }
    }
    public Student_(string newStuID)
    {
        Studentid = newStuID;
    }

    public string FirstName
    {
        get
        {
            throw new System.NotImplementedException();
        }
        set
        {
        }
    }

    public string LastName
    {
        get
        {
            throw new System.NotImplementedException();
        }
        set
        {
        }
    }

    public string MiddleInitial
    {
        get
        {
            throw new System.NotImplementedException();
        }
        set
        {
        }
    }

    public string FullName
    {
        get
        {
            return FirstName + MiddleInitial + LastName;
        }
    }

    public string CurrentEnrolledCourse
    {
        get
        {
            throw new System.NotImplementedException();
        }
        set
        {

        }
    }

    private int pointsearned { get; set; }
    private int pointspossible { get; set; }

    public int CurrentCourseAverage
    {
        get
        {
            return pointsearned / pointspossible;
        }
        set
        {
            if (value >= 0)

                CurrentCourseAverage = 100;
        }
    }

    public string CurrentCourseGrade
    {

        set
        {
            if (CurrentCourseAverage >= 90)
            {
                Console.WriteLine("A");
            }
            else if (CurrentCourseAverage >= 80)
            { // grade must be B, C, D or F
                Console.WriteLine("B");
            }
            else if (CurrentCourseAverage >= 70)
            { // grade must be C, D or F
                Console.WriteLine("C");
            }
            else if (CurrentCourseAverage >= 60)
            { // grade must D or F
                Console.WriteLine("D");
            }
            else
            {
                Console.WriteLine("F");
            }

        }
    }





    public void Enroll(string CurrentEnrolledCourse)
    {



        Console.WriteLine("Course: {0}", CurrentEnrolledCourse);

    }
    public void Drop()
    {
        //stuff
        CurrentEnrolledCourse = null;
        pointspossible = 0;
        pointsearned = 0;
    }


    public void AddGrade(int totalpointspossible, int totalpointsearned)
    {
        int newGrade = pointsearned + totalpointsearned;
        int NewGrade_ = pointspossible = totalpointspossible;

        if (CurrentEnrolledCourse != null)
        {
            return;
        }
        else { }
    }



    public bool IsEnrolled()
    {
        if (CurrentEnrolledCourse != null)
        {
            return false;
        }
        else
        {
            return true;
            }
        }



    }
}


What I have tried:

I haven't been able to figure it out but im stuck here
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test1_Student_Enroll
{
    class Program
    {
        static void Main(string[] args)
        {
            Student_ 100 = new Student("Karen","Stacey",
        }
    }
}
Posted
Updated 1-Mar-16 20:21pm
v2
Comments
Matt T Heffron 1-Mar-16 22:39pm    
There's so much wrong with this code there's no point in me starting to explain all of it.
You first need to learn the syntax of C# and the basics of programming.
Go back to your course notes.
Ask the instructor, or teaching assistant, or a classmate.

To start, this is what your class should start out as:


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

namespace Test1_Student_Enroll
{
    public class Student_
    {
        public string  Studentid { get; set; }
        
        public Student_(string newStuID)
        {
            Studentid = newStuID;
        }

        public string FirstName { get; set; }

        public string LastName { get; set; }
     

        public string MiddleInitial { get; set; }
        

        public string FullName
        {
            get
            {
                return FirstName + MiddleInitial + LastName;
            }
        }

        public string CurrentEnrolledCourse { get; set; }
        
        private int pointsearned { get; set; }
        private int pointspossible { get; set; }

        public int CurrentCourseAverage
        {
            get
            {
                return pointsearned / pointspossible;
            }
            set
            {
                if (value >= 0)

                    CurrentCourseAverage = 100;
            }
        }

        public string CurrentCourseGrade
        {

            set
            {
                if (CurrentCourseAverage >= 90)
                {
                    Console.WriteLine("A");
                }
                else if (CurrentCourseAverage >= 80)
                { // grade must be B, C, D or F
                    Console.WriteLine("B");
                }
                else if (CurrentCourseAverage >= 70)
                { // grade must be C, D or F
                    Console.WriteLine("C");
                }
                else if (CurrentCourseAverage >= 60)
                { // grade must D or F
                    Console.WriteLine("D");
                }
                else
                {
                    Console.WriteLine("F");
                }

            }
        }





        public void Enroll(string CurrentEnrolledCourse)
        {
            Console.WriteLine("Course: {0}", CurrentEnrolledCourse);
        }
        public void Drop()
        {
            //stuff
            CurrentEnrolledCourse = null;
            pointspossible = 0;
            pointsearned = 0;
        }


        public void AddGrade(int totalpointspossible, int totalpointsearned)
        {
            int newGrade = pointsearned + totalpointsearned;
            int NewGrade_ = pointspossible = totalpointspossible;

            if (CurrentEnrolledCourse != null)
            {
                return;
            }
            else { }
        }



        public bool IsEnrolled()
        {
            if (CurrentEnrolledCourse != null)
            {
                return false;
            }
            else
            {
                return true;
            }
        }
    }
}



in main

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test1_Student_Enroll
{
class Program
{
static void Main(string[] args)
{
    Student_ one = new Student('Karen');
    Student_ two = new Student('Stacy');
    Student_ three = new Student('Steve');

}
}
}
 
Share this answer
 
v2
Comments
Member 12362899 2-Mar-16 18:27pm    
Thank you so much! Youre a life saver
Hi,

Create object of student classes and assign the details that is required for each students. If you need to enroll for 3 students then you can create 3 different object of the student class and assign the respective data to the properties of the class object and you can use the objects separately to save the details.

Thanks,
Sisir Patro
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900