Answer to Question #25935 in C# for ISAA

Question #25935
Write a C # console application which contains two classes:
1. The first class “person” contain 4 attributes:
* PersonId which is a private integer.
* Name and Graduation which are public string.
* Age which is a public integer.
And a public method “PersonnalInformation()”. The method should include commands that read the input values for each of the attributes above and then print the input values.
1
Expert's answer
2013-04-08T08:48:11-0400
Class Person
using System;

namespace Question_25935
{
public class Person
{
& /// <summary>
& /// Default constructor
& /// </summary>
& public Person()
& {
& }

& private int PersonId; &
& public string Name;
& public string Graduation;
& public int Age;
&
& public string PersonnalInformation(int id, string name, string graduation, int age)
& {
PersonId = id;
Name = name;
Graduation = graduation;
Age = age;
return string.Format("Person: {0}, Name: {1}, Graduation: {2}, Age: {3}", PersonId, Name, Graduation, Age);
& } &
}
}



Class Main
using System;

namespace Question_25935
{
class Program
{
& public static void Main(string[] args)
& {
Person person = new Person(); //Create object

Console.Write("Enter value of Person Id: ");
var id = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter value of Name: ");
var name = Console.ReadLine();
Console.Write("Enter value of Graduation: ");
var graduation = Console.ReadLine();
Console.Write("Enter value of Age: ");
var age = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(person.PersonnalInformation(id, name, graduation, age));
Console.WriteLine();
Console.Write("Press any key to continue . . . ");
Console.ReadKey(true);
& }
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

Ask Your question

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS