Skip to content

Commit

Permalink
Second Assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitmahajan7 committed Dec 27, 2024
1 parent 8fe7e99 commit 3395c2e
Show file tree
Hide file tree
Showing 306 changed files with 186,223 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added Assignment02/.vs/Assignment02/v17/.suo
Binary file not shown.
54 changes: 54 additions & 0 deletions Assignment02/.vs/Assignment02/v17/DocumentLayout.backup.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|d:\\cdac\\personal_gitdata\\msdotnet\\assignment02\\a2q2.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|solutionrelative:a2q2.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|d:\\cdac\\personal_gitdata\\msdotnet\\assignment02\\a2q1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|solutionrelative:a2q1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "A2Q2.cs",
"DocumentMoniker": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q2.cs",
"RelativeDocumentMoniker": "A2Q2.cs",
"ToolTip": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q2.cs",
"RelativeToolTip": "A2Q2.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-27T12:12:26.816Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "A2Q1.cs",
"DocumentMoniker": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q1.cs",
"RelativeDocumentMoniker": "A2Q1.cs",
"ToolTip": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q1.cs",
"RelativeToolTip": "A2Q1.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-27T12:12:24.638Z",
"EditorCaption": ""
}
]
}
]
}
]
}
54 changes: 54 additions & 0 deletions Assignment02/.vs/Assignment02/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"Version": 1,
"WorkspaceRootPath": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|d:\\cdac\\personal_gitdata\\msdotnet\\assignment02\\a2q2.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|solutionrelative:a2q2.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|d:\\cdac\\personal_gitdata\\msdotnet\\assignment02\\a2q1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{CA88E252-9A60-4D51-A177-8AF96B38A5BF}|Assignment02.csproj|solutionrelative:a2q1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 0,
"Children": [
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "A2Q2.cs",
"DocumentMoniker": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q2.cs",
"RelativeDocumentMoniker": "A2Q2.cs",
"ToolTip": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q2.cs",
"RelativeToolTip": "A2Q2.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAUAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-27T12:12:26.816Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "A2Q1.cs",
"DocumentMoniker": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q1.cs",
"RelativeDocumentMoniker": "A2Q1.cs",
"ToolTip": "D:\\CDAC\\Personal_GITData\\MsDotNet\\Assignment02\\A2Q1.cs",
"RelativeToolTip": "A2Q1.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-12-27T12:12:24.638Z",
"EditorCaption": ""
}
]
}
]
}
]
}
7 changes: 7 additions & 0 deletions Assignment02/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ExpandedNodes": [
""
],
"SelectedNode": "\\Assignment02.sln",
"PreviewInSolutionExplorer": false
}
Binary file added Assignment02/.vs/slnx.sqlite
Binary file not shown.
107 changes: 107 additions & 0 deletions Assignment02/A2Q1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.Remoting.Messaging;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Build.Logging.StructuredLogger;

namespace Assignment02
{
public struct Student
{

private string name;
private bool gender;
private int age;
private int std;
private char div;
private double marks;

public Student(bool gender, string name, int age, int std, char div, double marks)
{
this.gender = gender;
this.name = name;
this.std = std;
this.age = age;
this.div = div;
this.marks = marks;

}

public string GetName() => name;
public string SetName(string value) => name = value;



public bool GetGender() => gender;
public bool SetGender(bool value) => gender = value;

public int GetAge() => age;
public void SetAge(int value) => age = value;

public int GetStd() => std;
public void SetStd(int value) => std = value;

public char GetDiv() => div;
public void SetDiv(char value) => div = value;

public double GetMarks() => marks;
public void SetMarks(double value) => marks = value;

public void AcceptDetails() {

Console.WriteLine("Enter the name: ");
SetName(Console.ReadLine() ) ;

Console.WriteLine("Enter the age: ");
SetAge(int.Parse(Console.ReadLine()));

Console.WriteLine("Enter the gender (true for Male, false for Female): ");
SetGender(bool.Parse(Console.ReadLine()));

Console.WriteLine("Enter the Std: ");
SetStd(int.Parse(Console.ReadLine()));

Console.WriteLine("Enter the Division: ");
SetDiv(Char.Parse(Console.ReadLine()));

Console.WriteLine("Enter the Marks: ");
SetMarks(int.Parse(Console.ReadLine()));


}

public void PrintDetails()
{
Console.WriteLine("\nStudent Details:");
Console.WriteLine("Name: " + name);
Console.WriteLine("Gender: " + (gender ? "Male" : "Female"));
Console.WriteLine("Age: " + age);
Console.WriteLine("Standard: " + std);
Console.WriteLine("Division: " + div);
Console.WriteLine("Marks: " + marks);
}
}

class Program
{
static void Main(string[] args)
{
// Using the default constructor
Student student1 = new Student();
Console.WriteLine("Enter details for student 1:");
student1.AcceptDetails();
student1.PrintDetails();

// Using the parameterized constructor
Student student2 = new Student(true, "XXX", 18, 12, 'A', 55 );
Console.WriteLine("\nDetails for student 2 (using parameterized constructor):");
student2.PrintDetails();
}
}

}


150 changes: 150 additions & 0 deletions Assignment02/A2Q2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Assignment02Q2
{


public struct Student
{

private string name;
private bool gender;
private int age;
private int std;
private char div;
private double marks;

public Student(bool gender, string name, int age, int std, char div, double marks)
{
this.gender = gender;
this.name = name;
this.std = std;
this.age = age;
this.div = div;
this.marks = marks;

}

public string GetName() => name;
public string SetName(string value) => name = value;



public bool GetGender() => gender;
public bool SetGender(bool value) => gender = value;

public int GetAge() => age;
public void SetAge(int value) => age = value;

public int GetStd() => std;
public void SetStd(int value) => std = value;

public char GetDiv() => div;
public void SetDiv(char value) => div = value;

public double GetMarks() => marks;
public void SetMarks(double value) => marks = value;

public void AcceptDetails()
{

Console.WriteLine("Enter the name: ");
SetName(Console.ReadLine());

Console.WriteLine("Enter the age: ");
SetAge(int.Parse(Console.ReadLine()));

Console.WriteLine("Enter the gender (true for Male, false for Female): ");
SetGender(bool.Parse(Console.ReadLine()));

Console.WriteLine("Enter the Std: ");
SetStd(int.Parse(Console.ReadLine()));

Console.WriteLine("Enter the Division: ");
SetDiv(Char.Parse(Console.ReadLine()));

Console.WriteLine("Enter the Marks: ");
SetMarks(int.Parse(Console.ReadLine()));


}

public void PrintDetails()
{
Console.WriteLine("\nStudent Details:");
Console.WriteLine("Name: " + name);
Console.WriteLine("Gender: " + (gender ? "Male" : "Female"));
Console.WriteLine("Age: " + age);
Console.WriteLine("Standard: " + std);
Console.WriteLine("Division: " + div);
Console.WriteLine("Marks: " + marks);
}
}

class Program
{

static void CreateArray(ref Student[] students)
{
Console.WriteLine("Enter the Number of Students: ");
int size = (int.Parse(Console.ReadLine()));

students = new Student[size];

Console.WriteLine("Array of size " + size + " created");

}

static void AcceptInfo(Student[] students)
{

Console.WriteLine("Enter Student Details: ");
for (int i = 0; i < students.Length; i++)
{
Console.WriteLine($"\nStudent {i + 1}:");
students[i].AcceptDetails();
}

}

static void PrintInfo(Student[] students)
{
Console.WriteLine("\nStudent details:");
for (int i = 0; i < students.Length; i++)
{
Console.WriteLine($"\nStudent {i + 1}:");
students[i].PrintDetails();
}
}
static void ReverseArray(Student[] students, ref Student[] reversedArray)
{
int size = students.Length;
reversedArray = new Student[size];

for (int i = 0; i < size; i++)
{
reversedArray[i] = students[size - 1 - i];
}

Console.WriteLine("\nArray has been reversed.");
}

static void Main(string[] args)
{
Student[] students = null;
Student[] reversedArray = null;

CreateArray(ref students);
AcceptInfo(students);
PrintInfo(students);

ReverseArray(students, ref reversedArray);
Console.WriteLine("\nReversed student details:");
PrintInfo(reversedArray);
}
}
}
6 changes: 6 additions & 0 deletions Assignment02/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
Loading

0 comments on commit 3395c2e

Please sign in to comment.