SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
#### This Is my code so far for the student class Need help with rest in C# will Upvote########
namespace Midterm_Challenge;
enum Status
{
Freshman,
Sophomore,
Junior,
Senior
}
class Student
{
private string firstName;
private string lastName;
private string major;
private int creditHours;
private int score1;
private int score2;
private int score3;
private Status classStatus;
public Student(string firstName, string lastName, string major, int creditHours, int score1, int
score2, int score3)
{
this.firstName = firstName;
this.lastName = lastName;
this.major = major;
this.creditHours = creditHours;
this.score1 = score1;
this.score2 = score2;
this.score3 = score3;
SetClassStatus();
}
public string FirstName
{
get { return firstName; }
set { firstName = value; }
}
public string LastName
{
get { return lastName; }
set { lastName = value; }
}
public string Major
{
get { return major; }
set { major = value; }
}
public int CreditHours
{
get { return creditHours; }
set
{
creditHours = value;
SetClassStatus();
}
}
private void SetClassStatus()
{
if (creditHours < 30)
{
classStatus = Status.Freshman;
}
else if (creditHours < 60)
{
classStatus = Status.Sophomore;
}
else if (creditHours < 90)
{
classStatus = Status.Junior;
}
else
{
classStatus = Status.Senior;
}
}
public void AddCreditHours(int amount)
{
creditHours += amount;
SetClassStatus();
}
public string GetFullName()
{
return $"{firstName} {lastName}";
}
public double CalculateAverageScore()
{
return (score1 + score2 + score3) / 3.0;
}
public char GetLetterGrade()
{
double averageScore = CalculateAverageScore();
if (averageScore >= 90)
{
return 'A';
}
else if (averageScore >= 80)
{
return 'B';
}
else if (averageScore >= 70)
{
return 'C';
}
else if (averageScore >= 60)
{
return 'D';
}
else
{
return 'F';
}
}
public void PrintStudentInfo()
{
Console.WriteLine($"{GetFullName()}: {classStatus} ({major})");
Console.WriteLine($"Average Score: {CalculateAverageScore()}% - Grade: {GetLetterGrade()}");
}
}
Purpose: This project will test your knowledge of many the topics we have covered so for in the
course; specifically OOP, file streams, loops, lists. Requirements: Project Name: MidtermProject
Target Platform: .NET Core Console Application Programming Language: C# Data File Download
the student data.csv file and place it in your C# program. The structure of the data in the file is as
follows: first name,last name,credit hours,major,exam1_score,exam2_score,exam3_score The
Student Class The Student class should be created in a file called Student.cs. constructor. Hint:
you will have to create a method that sets the classStatus based on credithours, so you can call
that method in the constructor. The Student class should also have methods that: - Get methods
for - Set methods for firstName, lastName, major. The Student class should also contain the
following methods: (25+10). Because an increase in credithours can result in a change
classStatus, this method should also then update the classStatus property. - Hint: You can call the
method that sets the classstatus from the method after you update the - A method that returns the
students full name "firstname lastname" as one string. - A method that calculates the student's
average score of their three scores - A method that returns the letter grade based on the average
(A: 90-100, B: 8089,C:7079, D: 60 - 69, F: less than 60) - Hint: you can call the method that gets
the average score from this method - A method that prints the student's information in the
following format - [Student name]: [student class][[major]) - Average Score: [student average]% --
Grade: [letter grade]Workng on the Project The best way to complete this challenge is to first
create the Student class, get it working, and test it. Your project should: - read the data from the
student csv file and create a new student for each student in the file. Here is a link to resources for
files handling in C# - Add all the students to a list of students. You can create a list of type
Student. Example code below - List < Student > myList = new List < Student >(); - Print each
student's information to the console. It should look like the following sample output but for all of the
students: - Tyler Rees: Senior(Instrumental Music) Average Score: 86.74%-- Grade: B Liam Lowe:
Sophomore(Journalism) Average Score: 78.16%-- Grade: C George Wright: Senior(Biology)
Average Score: 61.39%-- Grade: D Naomi Williams: Junior(Journalism) Average Score: 82.23%--
Grade: B - Write a report where you also write each student's information to a text file named You
can test your code with the following code in the Program.cs file. You should leave this code in
your project at the bottom of the Main method in your Program.cs file //Miderm Test Code Student
teststudent = new Student("Truman", "Tiger", 87, "Journa1ism", 91.2, 82.5, 93.4);
teststudent.printstudentinfo( ) teststudent. addHours (10); teststudent setFirstName("Tracy");
teststudent. setlastNane("Turtle"); teststudent. setMajor("Comunications");
teststudent.printstudentinfo( ); Test Code Output Truman Tiger: Junior(Journalism) Average
Score: 89.03%.. Grade: B Tracy Turtle: Senior(Comunications) Average Score: 89.03%-. Grade: B

Mais conteúdo relacionado

Semelhante a This Is my code so far for the student class Need help .pdf

HS2021 Database Design and UseWeek 2 - 2020 Tutorial
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial        HS2021 Database Design and UseWeek 2 - 2020 Tutorial
HS2021 Database Design and UseWeek 2 - 2020 Tutorial
troutmanboris
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
ShiraPrater50
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
Syed Faizan Hassan
 
Classification examp
Classification exampClassification examp
Classification examp
Ryan Hong
 
Java căn bản - Chapter13
Java căn bản - Chapter13Java căn bản - Chapter13
Java căn bản - Chapter13
Vince Vo
 
COP2800 - Java Programming Course Project Fall 2014 Page .docx
COP2800 - Java Programming  Course Project Fall 2014 Page .docxCOP2800 - Java Programming  Course Project Fall 2014 Page .docx
COP2800 - Java Programming Course Project Fall 2014 Page .docx
maxinesmith73660
 

Semelhante a This Is my code so far for the student class Need help .pdf (11)

SQL
SQLSQL
SQL
 
SQL
SQL SQL
SQL
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial        HS2021 Database Design and UseWeek 2 - 2020 Tutorial
HS2021 Database Design and UseWeek 2 - 2020 Tutorial
 
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx        HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
HS2021 Database Design and UseWeek 2 - 2020 Tutorial.docx
 
How to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programmingHow to write you first class in c++ object oriented programming
How to write you first class in c++ object oriented programming
 
CMSC 350 HOMEWORK 1
CMSC 350 HOMEWORK 1CMSC 350 HOMEWORK 1
CMSC 350 HOMEWORK 1
 
Classification examp
Classification exampClassification examp
Classification examp
 
Section1 compound data class
Section1 compound data classSection1 compound data class
Section1 compound data class
 
Java căn bản - Chapter13
Java căn bản - Chapter13Java căn bản - Chapter13
Java căn bản - Chapter13
 
Chapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and PolymorphismChapter 13 - Inheritance and Polymorphism
Chapter 13 - Inheritance and Polymorphism
 
COP2800 - Java Programming Course Project Fall 2014 Page .docx
COP2800 - Java Programming  Course Project Fall 2014 Page .docxCOP2800 - Java Programming  Course Project Fall 2014 Page .docx
COP2800 - Java Programming Course Project Fall 2014 Page .docx
 

Mais de ajay1317

The lemonade stands are perfectly competitive because A t.pdf
 The lemonade stands are perfectly competitive because A t.pdf The lemonade stands are perfectly competitive because A t.pdf
The lemonade stands are perfectly competitive because A t.pdf
ajay1317
 
Table Region .pdf
 Table Region  .pdf Table Region  .pdf
Table Region .pdf
ajay1317
 

Mais de ajay1317 (20)

0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf0 Suppose that a subsidy plan is introduced for lowincome .pdf
0 Suppose that a subsidy plan is introduced for lowincome .pdf
 
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
+ 1D 1W1M3M1Y5Y Your position Shares Market value 15 145.pdf
 
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf  proxyc  CSAPP Web proxy   NAME    IMPORTANT Giv.pdf
proxyc CSAPP Web proxy NAME IMPORTANT Giv.pdf
 
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 AIDS is a diagnostic term applied to HIVinfected persons .pdf AIDS is a diagnostic term applied to HIVinfected persons .pdf
AIDS is a diagnostic term applied to HIVinfected persons .pdf
 
Three Theories of DNA Replication Who were the two scien.pdf
 Three Theories of DNA Replication  Who were the two scien.pdf Three Theories of DNA Replication  Who were the two scien.pdf
Three Theories of DNA Replication Who were the two scien.pdf
 
The lemonade stands are perfectly competitive because A t.pdf
 The lemonade stands are perfectly competitive because A t.pdf The lemonade stands are perfectly competitive because A t.pdf
The lemonade stands are perfectly competitive because A t.pdf
 
This program reads a decimal array and outputs each numb.pdf
 This program reads a decimal array and outputs each  numb.pdf This program reads a decimal array and outputs each  numb.pdf
This program reads a decimal array and outputs each numb.pdf
 
Two novice business students come to their professor and a.pdf
 Two novice business students come to their professor and a.pdf Two novice business students come to their professor and a.pdf
Two novice business students come to their professor and a.pdf
 
Un mtodo operativo para administrar el inventario es la i.pdf
 Un mtodo operativo para administrar el inventario es la i.pdf Un mtodo operativo para administrar el inventario es la i.pdf
Un mtodo operativo para administrar el inventario es la i.pdf
 
Table Region .pdf
 Table Region  .pdf Table Region  .pdf
Table Region .pdf
 
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 Supongamos que la Tierra gir hacia atrs pero an orbita.pdf Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
Supongamos que la Tierra gir hacia atrs pero an orbita.pdf
 
Synthesizes the new DNA strands in the 5 3 direction .pdf
 Synthesizes the new DNA strands in the 5 3 direction  .pdf Synthesizes the new DNA strands in the 5 3 direction  .pdf
Synthesizes the new DNA strands in the 5 3 direction .pdf
 
returns a new copy of the LinkedList It creates a copy .pdf
 returns a new copy of the LinkedList It creates a copy .pdf returns a new copy of the LinkedList It creates a copy .pdf
returns a new copy of the LinkedList It creates a copy .pdf
 
Sony Ericsson is a global company that was established in .pdf
 Sony Ericsson is a global company that was established in .pdf Sony Ericsson is a global company that was established in .pdf
Sony Ericsson is a global company that was established in .pdf
 
11 ST segment depression may indicate Ischemia Normal fin.pdf
 11 ST segment depression may indicate Ischemia Normal fin.pdf 11 ST segment depression may indicate Ischemia Normal fin.pdf
11 ST segment depression may indicate Ischemia Normal fin.pdf
 
Realice una investigacin adicional para obtener ms infor.pdf
 Realice una investigacin adicional para obtener ms infor.pdf Realice una investigacin adicional para obtener ms infor.pdf
Realice una investigacin adicional para obtener ms infor.pdf
 
Elvira es una pintora abstracta con un talento increble p.pdf
 Elvira es una pintora abstracta con un talento increble p.pdf Elvira es una pintora abstracta con un talento increble p.pdf
Elvira es una pintora abstracta con un talento increble p.pdf
 
Programming Assignment 4 Calculate the first 16 Fib.pdf
 Programming Assignment 4  Calculate the first 16 Fib.pdf Programming Assignment 4  Calculate the first 16 Fib.pdf
Programming Assignment 4 Calculate the first 16 Fib.pdf
 
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 El sndrome X frgil es un trastorno dominante ligado al s.pdf El sndrome X frgil es un trastorno dominante ligado al s.pdf
El sndrome X frgil es un trastorno dominante ligado al s.pdf
 
In grading eggs into small medium and large the Nancy F.pdf
 In grading eggs into small medium and large the Nancy F.pdf In grading eggs into small medium and large the Nancy F.pdf
In grading eggs into small medium and large the Nancy F.pdf
 

Último

1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Krashi Coaching
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
fonyou31
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Último (20)

Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 

This Is my code so far for the student class Need help .pdf

  • 1. #### This Is my code so far for the student class Need help with rest in C# will Upvote######## namespace Midterm_Challenge; enum Status { Freshman, Sophomore, Junior, Senior } class Student { private string firstName; private string lastName; private string major; private int creditHours; private int score1; private int score2; private int score3; private Status classStatus; public Student(string firstName, string lastName, string major, int creditHours, int score1, int score2, int score3) { this.firstName = firstName; this.lastName = lastName; this.major = major; this.creditHours = creditHours; this.score1 = score1; this.score2 = score2; this.score3 = score3; SetClassStatus(); } public string FirstName { get { return firstName; } set { firstName = value; } } public string LastName { get { return lastName; } set { lastName = value; } } public string Major
  • 2. { get { return major; } set { major = value; } } public int CreditHours { get { return creditHours; } set { creditHours = value; SetClassStatus(); } } private void SetClassStatus() { if (creditHours < 30) { classStatus = Status.Freshman; } else if (creditHours < 60) { classStatus = Status.Sophomore; } else if (creditHours < 90) { classStatus = Status.Junior; } else { classStatus = Status.Senior; } } public void AddCreditHours(int amount) { creditHours += amount; SetClassStatus(); } public string GetFullName() { return $"{firstName} {lastName}"; } public double CalculateAverageScore()
  • 3. { return (score1 + score2 + score3) / 3.0; } public char GetLetterGrade() { double averageScore = CalculateAverageScore(); if (averageScore >= 90) { return 'A'; } else if (averageScore >= 80) { return 'B'; } else if (averageScore >= 70) { return 'C'; } else if (averageScore >= 60) { return 'D'; } else { return 'F'; } } public void PrintStudentInfo() { Console.WriteLine($"{GetFullName()}: {classStatus} ({major})"); Console.WriteLine($"Average Score: {CalculateAverageScore()}% - Grade: {GetLetterGrade()}"); } } Purpose: This project will test your knowledge of many the topics we have covered so for in the course; specifically OOP, file streams, loops, lists. Requirements: Project Name: MidtermProject Target Platform: .NET Core Console Application Programming Language: C# Data File Download the student data.csv file and place it in your C# program. The structure of the data in the file is as follows: first name,last name,credit hours,major,exam1_score,exam2_score,exam3_score The Student Class The Student class should be created in a file called Student.cs. constructor. Hint: you will have to create a method that sets the classStatus based on credithours, so you can call that method in the constructor. The Student class should also have methods that: - Get methods for - Set methods for firstName, lastName, major. The Student class should also contain the
  • 4. following methods: (25+10). Because an increase in credithours can result in a change classStatus, this method should also then update the classStatus property. - Hint: You can call the method that sets the classstatus from the method after you update the - A method that returns the students full name "firstname lastname" as one string. - A method that calculates the student's average score of their three scores - A method that returns the letter grade based on the average (A: 90-100, B: 8089,C:7079, D: 60 - 69, F: less than 60) - Hint: you can call the method that gets the average score from this method - A method that prints the student's information in the following format - [Student name]: [student class][[major]) - Average Score: [student average]% -- Grade: [letter grade]Workng on the Project The best way to complete this challenge is to first create the Student class, get it working, and test it. Your project should: - read the data from the student csv file and create a new student for each student in the file. Here is a link to resources for files handling in C# - Add all the students to a list of students. You can create a list of type Student. Example code below - List < Student > myList = new List < Student >(); - Print each student's information to the console. It should look like the following sample output but for all of the students: - Tyler Rees: Senior(Instrumental Music) Average Score: 86.74%-- Grade: B Liam Lowe: Sophomore(Journalism) Average Score: 78.16%-- Grade: C George Wright: Senior(Biology) Average Score: 61.39%-- Grade: D Naomi Williams: Junior(Journalism) Average Score: 82.23%-- Grade: B - Write a report where you also write each student's information to a text file named You can test your code with the following code in the Program.cs file. You should leave this code in your project at the bottom of the Main method in your Program.cs file //Miderm Test Code Student teststudent = new Student("Truman", "Tiger", 87, "Journa1ism", 91.2, 82.5, 93.4); teststudent.printstudentinfo( ) teststudent. addHours (10); teststudent setFirstName("Tracy"); teststudent. setlastNane("Turtle"); teststudent. setMajor("Comunications"); teststudent.printstudentinfo( ); Test Code Output Truman Tiger: Junior(Journalism) Average Score: 89.03%.. Grade: B Tracy Turtle: Senior(Comunications) Average Score: 89.03%-. Grade: B