Exercise
1
Tulis script atau kode di Notepad,
using System;
classGeometrical_Shapes
{
double
No_of_coordinates;
double
Area;
string
Color;
publicvoid
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();
}
publicvoid
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);
}
}
classClassy
{
staticvoid
Main(String[] args)
{
Geometrical_Shapes Small_rectangle= new Geometrical_Shapes ();
Small_rectangle.Create();
Small_rectangle.Display();
Console.ReadLine();
}
}
Simpan dengan ekstensi .cs , Kemudian buka Visual Studio Command Prompt, Masuk pada drive mana kita menyimpan File Notepad dengan ekstensi .cs. Jalankan program dengan perintah csc (Nama File yang kita simpan .cs), ketika program telah dijalankan, masuk pada Drive yang kita gunakan untuk menyimpan File Notepad tadi, lalu jalankan Program yang telah jadi dengan ektensi .exe.
File
.exe
Exercise
2
using System;
classGameDetails
{
string Fname;
string Lname;
int noOfPlayers;
int Level;
publicvoid 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 player:");
noOfPlayers = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter
complexity level number:");
Level = Convert.ToInt32(Console.ReadLine());
}
publicvoid Display_game_details()
{
Console.WriteLine("\nThe
details entered are follows:");
Console.Write("First
name:");
Console.WriteLine(Fname);
Console.Write("Last
name:");
Console.WriteLine(Lname);
Console.Write("Number
of player:");
Console.WriteLine(noOfPlayers);
Console.Write("Level:");
Console.WriteLine(Level);
}
}
classmy
{
staticvoid Main(string[]
args)
{
GameDetails Bingo = new GameDetails();
Bingo.Accept_game_details();
Bingo.Display_game_details();
Console.ReadLine();
}
}
File
.exe
Exercise
3
using System;
classMyclass
{
staticvoid Main()
{
string Answer = "Y";
string Response_code = "66";
int Counter = 60;
Console.WriteLine(Answer);
Console.WriteLine(Response_code);
Console.WriteLine(Counter);
Console.ReadLine();
}
}
File
.exe
Exercise
4
using System;
classVehicle
{
publicint Number_of_tyres;
}
classMyVehicle
{
staticvoid Main(string[]
args)
{
Vehicle Motorcycle = new Vehicle();
Vehicle Car = new
Vehicle();
Console.WriteLine("Enter
the number or wheels in a car:");
Car.Number_of_tyres = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter
the number of wheels on a Motorcycle:");
Motorcycle.Number_of_tyres = Convert.ToInt32(Console.ReadLine());
Console.Write("\nThe
number of wheels on a var is ");
Console.WriteLine(Car.Number_of_tyres);
Console.Write("The
number of wheels in a Motorcycle is ");
Console.WriteLine(Motorcycle.Number_of_tyres);
Console.ReadLine();
}
}
File
.exe
Exercise
5
using System;
classInterchange
{
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 calue of top score is:");
Console.WriteLine(Top_score);
Console.WriteLine("The
old value of top score was:");
Console.WriteLine(New_score);
Console.ReadLine();
}
staticvoid Main()
{
Interchange I1=new
Interchange();
I1.Swap();
I1.Display();
}
}
File
.exe
Exercise
6
using System;
classLibrary
{
int ISBNNumber;
string BookCategory;
string Author;
int NumberOfCopyAvailable;
publicvoid Borrowing_Book_Details()
{
Console.WriteLine("The
Details of the Author Book:");
Console.WriteLine("ISBN
Number:");
Console.WriteLine(ISBNNumber);
Console.WriteLine("Book
Category:");
Console.WriteLine(BookCategory);
Console.WriteLine("Author
Name:");
Console.WriteLine(Author);
Console.WriteLine("Number
of copies acailable:");
Console.WriteLine(NumberOfCopyAvailable);
}
publicvoid Get_Author_Details()
{
Console.WriteLine("Please,
Enter the details of the Author");
Console.WriteLine("\n
Enter ISBNNumber:");
ISBNNumber = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Category
of Books to be borrow (Fiction or Nonfiction):");
BookCategory = Console.ReadLine();
Console.WriteLine("Enter
Author Book Name:");
Author = Console.ReadLine();
Console.WriteLine("Number
Of Copy Available:");
NumberOfCopyAvailable = Convert.ToInt32(Console.ReadLine());
}
}
classOKi
{
publicstaticvoid Main(string[] args)
{
Library L1 = new
Library();
L1.Borrowing_Book_Details();
L1.Get_Author_Details();
Console.ReadLine();
}
}
File
.exe
Oki Ria Hermawan
1203040011