EXERCISE 1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Geometrical_Shapes
{
double No_of_coordinates;
double Area;
string Color;
public void Create()
{
Console.WriteLine("Enter number of coordinates: ");
No_of_coordinates=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter the Area: ");
Area=Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter the Color: ");
Color=Console.ReadLine();
}
public void Display()
{
Console.WriteLine("THIS IS WHAT YOU ENTERED: \n");
Console.Write("Number of Coordinates: ");
Console.WriteLine(No_of_coordinates);
Console.Write("Area: ");
Console.WriteLine(Area);
Console.Write("Color: ");
Console.WriteLine(Color);
}
}
class Classy
{
static void Main(string[] args)
{
Geometrical_Shapes Small_rectangle= new Geometrical_Shapes();
Small_rectangle.Create();
Small_rectangle.Display();
Console.ReadLine();
}
}
EXERCISE 2
using System;
class GameDetails
{
string Fname;
string Lname;
int NoOfplayers;
int Level;
public void Accept_game_details()
{
Console.WriteLine("Enter your first name:");
Fname=Console.ReadLine();
Console.WriteLine("Enter your last name:");
Lname=Console.ReadLine();
Console.WriteLine("Enter number of players:");
NoOfplayers= Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter complexity level number:");
Level=Convert.ToInt32(Console.ReadLine());
}
public void Display_game_details()
{
Console.WriteLine("\nThe details entered are as follows:");
Console.Write("First name: ");
Console.WriteLine(Fname);
Console.Write("Last name: ");
Console.WriteLine(Lname);
Console.Write("Number of players:");
Console.WriteLine(NoOfplayers);
Console.Write("Level:");
Console.WriteLine(Level);
}
}
class My
{
static void Main(string[] args)
{
GameDetails Bingo= new GameDetails();
Bingo.Accept_game_details();
Bingo.Display_game_details();
}
}
EXERCISE 3
using System;
class Myclass
{
static void Main()
{
string Answer="Y";
string Response_code="66";
int Counter=60;
Console.WriteLine(Answer);
Console.WriteLine(Response_code);
Console.WriteLine(Counter);
Console.ReadLine();
}
}
EXERCISE 4
using System;
class Vehicle
{
public int Number_of_tyres;
}
class MyVehicle
{
static void Main (string[] args)
{
Vehicle Motorcycle= new Vehicle();
Vehicle Car= new Vehicle();
Console.WriteLine("Enter the number of wheels in a car:");
Car.Number_of_tyres=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the number of wheels in a Motorcycle:");
Motorcycle.Number_of_tyres=Convert.ToInt32(Console.ReadLine());
Console.Write("\nThe number of wheels in a Car is ");
Console.WriteLine(Car.Number_of_tyres);
Console.Write("\nThe number of wheels in a Motorcycle is ");
Console.WriteLine(Motorcycle.Number_of_tyres);
}
}
EXERCISE 5
using System;
class Interchange
{
int Top_score;
int New_score;
int Temp;
void Swap()
{
Top_score=5;
New_score=10;
Temp=Top_score;
Top_score = New_score;
New_score = Temp;
}
void Display()
{
Console.WriteLine("The new value of top score is:{0}",New_score);
Console.WriteLine("The old value of top score was:" + Top_score);
Console.ReadLine();
}
static void Main()
{
Interchange I1=new Interchange();
I1.Swap();
I1.Display();
Console.ReadLine();
}
}
EXERCISE 6
using System;
class Books
{
int Number;
int Copies;
string Category;
string Author;
public void Create()
{
Console.WriteLine("Enter the ISBN Number: ");
Number=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter the Book Category (Fiction / Nonfiction): ");
Category=Console.ReadLine();
Console.WriteLine("Enter the Author: ");
Author=Console.ReadLine();
Console.WriteLine("Enter the number of copies available: ");
Copies=Convert.ToInt32(Console.ReadLine());
}
public void Display()
{
Console.WriteLine("THIS IS THE BOOK DETAILS THAT YOU ENTERED: \n");
Console.Write("ISBN Number: ");
Console.WriteLine(Number);
Console.Write("Book Category: ");
Console.WriteLine(Category);
Console.Write("Author: ");
Console.WriteLine(Author);
Console.Write("Number of copies available: ");
Console.WriteLine(Copies);
}
}
class LibraryBook
{
static void Main(string[] args)
{
Books Putri = new Books();
Putri.Create();
Putri.Display();
Console.ReadLine();
}
}