St. Joseph school planned to create a system to store the records of students studying in their school. They need to store various kinds of data about their students. Write a C# program based on the class diagram given below and initialize the variables with proper values and print it
SCHOOL DEMO:
rollNumber : int
studentName : string
age : bytr
gender : char
dateOfBirth : DateTime
address : string
precentage : float
using System;
public class Program
{
public static void Main()
{
//Create object of type SCHOOL_DEMO
SCHOOL_DEMO sd = new SCHOOL_DEMO();
//Invoke display method
sd.display();
}
}
//Crate the class
class SCHOOL_DEMO
{
//Create student data and initialize them
private int rollNumber = 20000;
private String studentName = "John Doe";
private byte age = 15;
private char gender = 'M';
DateTime dateOfBirth = new DateTime(2006,05,09);
private String address = "36 Sherwood Street Horn Lake, MS 38637";
private float percentage = 88.70F;
//Display student information
public void display()
{
Console.WriteLine("========Student Summary========");
Console.WriteLine("Roll Number: {0}", this.rollNumber );
Console.WriteLine("Student Name: {0}" , this.studentName );
Console.WriteLine("Age: {0}" , this.age );
Console.WriteLine("Gender: "+ this.gender );
Console.WriteLine("DoB: "+ this.dateOfBirth.ToShortDateString() );
Console.WriteLine("Address: "+ this.address);
Console.WriteLine("Percentage: {0}% ", this.percentage );
}
}
Comments
Leave a comment