Project #3912 - C# Programming Project

 (25 points) Create a console application and call it Assignment5. Now perform the following steps:

a.       Download the Person.cs file and place it in the same folder as the Program.cs file.

b.      In Visual Studio, use Project > Add Existing Item (the Add Existing Item menu item in the Project tab) to add the Person.cs file (i.e. the Person class) to your Assignment5 project.

c.       Add the ClassAndObject namespace to your Assignment5 project with the using keyword.

d.      Create an enumeration called StandingEnum that contains the following values: Freshman, Sophomore, Junior, and Senior. The enumeration should be defined at the namespace level.

e.      Create a class named Student that extends the Person class (defined inside the Person.cs file). Extending the Person class means the Student class will inherit from the Person class.

f.        Add the following fields to the Student class: string studentID, StandingEnum standing.

g.       Change the DisplayInfo() method in the Person class to a virtual method.

h.      Define an override method named DisplayInfo() in the Student class. Assuming these values: First Name = “Joe”, Last Name = “Smith”, Age = 18, Student ID = “11111”, and Standing = Freshman; the output from the overload DisplayInfo() method would  be

Student ID: 11111
Standing: Freshman
First Name: Joe
Last Name: Smith
Age: 18

i.         Create a Student object named myStudent.

j.        Using acceptable prompts (e.g. Enter First Name: ), accept input from the keyboard for the myStudents object’s first name, last name, age, student ID, and standing.

k.       For standing, use this prompt: “Enter Standing (1=Freshman, 2=Sophomore, 3=Junior, 4=Senior: “. Keep in mind this means you will need to subtract 1 from the value entered to get the correct enumeration value. See my video on enumerations.

l.         After entering the student information, print the output from the FullName() student method and the DisplayInfo() student method to the console. Assuming the student information in h. above, the output would look like this:

Joe Smith

Student ID: 11111
Standing: Freshman
First Name: Joe
Last Name: Smith
Age: 18

2.       (50 points) Check for correct user input by throwing and catching Exception objects as described below:

a.       If you haven’t already done so, view my TryCatch video. If you have viewed it, you might consider viewing it again.

b.      Place a do while() loop around the Console.WriteLine() prompts and Console.ReadLine() inputs for part 1. First Name, Last Name, Age, Student ID, and Standing should be contained in their own do while() loop for a total of 5 do while() loops.

c.       Inside each do while() loop use a try..catch to test for acceptable input from your user. Acceptable input means neither the system nor your code through an exception object.

d.      Create a class named MyEmptyStringException that extends the Exception class. Create a constructor method for MyEmptyStringException that accepts a message of type string and passes the message to the base(message) constructor. This is demonstrated in my TryCatch video where I create a myOutOfRangeException class.

e.      If First Name is left blank by the user your code should throw and catch a MyEmptyStringException object, passing the object an appropriate message (e.g. First Name can NOT be left blank!) that is output to the screen.

f.        Repeat step e. for Last Name and Student ID.

g.       Repeat step d. to create a MyOutOfRangeException.

h.      Repeat step e. for Age with the following modifications:

·   Your code should catch the System exceptions FormatException and OverflowException.

·   Your code should NOT throw a MyEmptyStringException.

·   If the value entered for Age is not between 15 and 70 your code should throw and catch a MyOutOfRangeException, passing the object an acceptable message (e.g. Age must be between 15 and 70), which should be output to the console.

i.         Repeat step h. for Standing, except the acceptable values are 1, 2, 3, or 4.

 

 

I will need to e-mail the .cs file because it won't allow me to upload it. 

Subject Computer
Due By (Pacific Time) 04/07/2013 12:00 am
Report DMCA
TutorRating
pallavi

Chat Now!

out of 1971 reviews
More..
amosmm

Chat Now!

out of 766 reviews
More..
PhyzKyd

Chat Now!

out of 1164 reviews
More..
rajdeep77

Chat Now!

out of 721 reviews
More..
sctys

Chat Now!

out of 1600 reviews
More..
sharadgreen

Chat Now!

out of 770 reviews
More..
topnotcher

Chat Now!

out of 766 reviews
More..
XXXIAO

Chat Now!

out of 680 reviews
More..
All Rights Reserved. Copyright by AceMyHW.com - Copyright Policy