Professional Documents
Culture Documents
Exercises
Exercises
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text;
using System.Threading.Tasks;
namespace LabReviewBeforeExam
{
internal class Program
{
static void Main(string[] args)
{
/* ============================ Data Types with Implicit and Explicit
Casting ========================================*/
/*Ex(1): Write a program that allows employees to enter their names and
ID with printing both. By using string and and int variables*/
/*
-----------------------------------------------------------------------------------
------------------------------------ */
/* EX(2): Write a program that enables user to calculate the Net Income
of XYZ company
* NOTE: Net Income = Revenues - Exepenses.
* NOTE: Revenues or exepenses may be double or float and we wanna in
this example to make it as rounded value.*/
/*
-----------------------------------------------------------------------------------
----------------------------------------- */
/*EX(3): write a calculator that take two numbers as string and then
printing as double numbers */
/* EX(1): Write a program that printing True if you enter the same
names and false if the names are different */
/* EX(1): Write a program printing Studen’t name and BIS level 3 when
he enter his name and enter his BIS level */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
}*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(3): Write program that prints a grade based on your GPA like 3 or
3.5 or 4*/
if (GPA < 2)
{
Console.WriteLine("Failed");
}
if(GPA>=2 && GPA <= 2.25)
{
Console.WriteLine("D");
}
if(GPA>=2.5 && GPA <= 2.75)
{
Console.WriteLine("C");
}
if(GPA>=3.00 && GPA <= 3.5)
{
Console.WriteLine("B");
}
if(GPA>=3.75 && GPA <= 4)
{
Console.WriteLine("A");
} */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(4): Write program to dermine the input number whether odd or even
*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
if (num > 0)
{
Console.WriteLine(num+" is positive");
}
else
{
Console.WriteLine(num + " is negative");
}*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* Console.WriteLine("Enter an integer:");
int number = int.Parse(Console.ReadLine());
i++;
}
*/
do
{
if (i % 2 == 0 && i > 0)
{
Console.WriteLine(i + " is even and positive");
}
if (i % 2 == 0 && i < 0)
{
Console.WriteLine(i + " is even and negative");
}
i++;
} while (i <= end_number);*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(3): Write program that make sum for even numbers only and
ignoring odd numbers */
if (the_number % 2 == 0)
{
sum += the_number;
}
}
Console.WriteLine("The total of even numbers is: "+sum);*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(5): Write program to print this pattern: NOTE: you can change '*'
to be numbers or letters
*
**
***
****
*****
*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
*******
* *
* *
* *
* *
* *
*******
*/
/* int number = 7;
}*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(3): Create a program that allows for entering 10 users for hiring
new employees in the XYZ company
then users who have age more than 30 and less than 21 will be
rejected from the application form.
You can use array for determing how to accept and reject and don’t
forget to allow users to enter their name and ages.
{
Console.WriteLine(Names[x] + " " + "Accepted!"); //Names[x]
changes for each time from [0] to [9] another index outside this range will be
error
else
{
Console.WriteLine(Names[x] + " " + "Rejected!");
}
/*
-----------------------------------------------------------------------------------
------------------------------------- */
*******
*******
*******
*******
*******
NOTE: You may use loop and array to translate this pattern to be
code. */
}
else
{
Console.WriteLine("As you like");
}
*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
sorting_names[i] = Console.ReadLine();
}
Console.WriteLine("Names after rearrangement are:");
Array.Sort(sorting_names);
foreach(string rearrange in sorting_names)
{
Console.WriteLine(rearrange);
}*/
2 3 4
5 6 7
8 9 1
*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(7): write a program to allow users to make his matrix which 3*3
or 2*2 or 5*5 based on user’s requirements: */
*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(8): By using two-dimensional array and for loop you are required
to write program that prints the following pattern:
*********
*********
*********
*********
*********
*/
/* ============================ Methods
=============================================================== */
/* EX(1): By using only one method write a program that printing the
following output:
/* name_age("ahmed", 24);
name_age("mohammed", 21);
name_age("mostafa", 24);*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(3): reference * هذا مثال توضيحي فقط الستخدام الدالة في وجود/
/* int i = 20;
// using_reference(i);
Console.WriteLine(i); // i before
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* EX(4): By using loop, methods and array write a program to take the
average of numbers user will enter them firstly: */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* static int odd_numbers(int num1, int num2, int num3, int num4)
{
}*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */
/* Accoring to the example (3) of methods */
/*
-----------------------------------------------------------------------------------
------------------------------------- */
Console.WriteLine(the_average);
}
}
*/
/*
-----------------------------------------------------------------------------------
------------------------------------- */