NUMBER PROGRAM using using using using System; System.Collections.Generic; System.Linq; System.

Text;

namespace Numbers1 { class Program { static void Main(string[] args) { Console.Write("Enter a number: "); int number = Convert.ToInt32(Console.ReadLine()); if (number == 0) { Console.Write("Your number is zero"); } else if (number < 0) { Console.Write("Your number is negative"); } else if (number > 0) { int checkIfEven = number % 2; if (checkIfEven == 0) { Console.Write("Your number is even"); } else if (checkIfEven != 0) { Console.Write("Your number is odd"); } } Console.ReadKey(); } } } ________________________________________________________________________________ ______________ SECOND NUMBER PROGRAM

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace number { class Program { static void Main(string[] args)

{ bool check = false; do { Console.WriteLine(); Console.Write("1.....Enter a number"); Console.WriteLine(); Console.Write("2.....Prime or odd?"); Console.WriteLine(); Console.Write("3.....CM to METERS"); Console.WriteLine(); Console.Write("4.....KM TO MILES"); Console.WriteLine(); Console.Write("5.....Exit"); Console.WriteLine(); Console.WriteLine(); Console.Write("Enter your option: "); int opt = Convert.ToInt32(Console.ReadLine().Trim()); switch (opt) { case 1: Console.Write("Enter a number: "); float numInput = Convert.ToSingle(Console.ReadLine() .Trim()); if (numInput < 0) { Console.WriteLine(); Console.Write("Your number is Console.ReadKey(); Console.Clear(); } else if (numInput == 0) { Console.WriteLine(); Console.Write("Your Number is Console.ReadKey(); Console.Clear(); } else { if (numInput % 2 == 0) { Console.WriteLine(); Console.Write("Its an Console.ReadKey(); Console.Clear(); } else { Console.WriteLine(); Console.Write("Its an Console.ReadKey(); Console.Clear(); } } break;

negative");

0");

even number");

odd numbrer");

case 2: Console.Write("Enter a number: "); int dividend = Convert.ToInt32(Console.ReadLin

e().Trim()); int numberOfDivisors = 0; int divisor = dividend; for (int i = divisor; i > 0; i--) { Console.WriteLine(); Console.Write(i); Console.Beep(2000, 1000); if (dividend % i == 0) numberOfDivisors++; } if ((numberOfDivisors > 2) && (dividend != 1)) { Console.WriteLine(); Console.Write("Not Prime"); Console.ReadKey(); } else if (numberOfDivisors == 2) { Console.WriteLine(); Console.Write("Prime"); Console.ReadKey(); } else { Console.WriteLine(); Console.Write("1 is nither a Prime nor a composite Number"); Console.ReadKey(); } break; } }while (check != true); } } } ________________________________________________________________________________ ______________ third NUMBER PROGrAM

using using using using

System; System.Collections.Generic; System.Linq; System.Text;

namespace numbers

{ class Program { static void Main(string[] args) { float[] Num; float sum = 0; float Ave = 0; bool check = false; do { Console.WriteLine(); Console.Write("1....Input numbers"); Console.WriteLine(); Console.Write("2....Output Sum"); Console.WriteLine(); Console.Write("3....Output Average"); Console.WriteLine(); Console.Write("4....Exit"); Console.WriteLine(); Console.WriteLine(); Console.Write("Enter number to choose: "); int option = Convert.ToInt32(Console.ReadLine()); switch (option) { case 1: Console.Write("How many numbers you want to enter?"); Console.WriteLine(); int loopNum = Convert.ToInt32(Console.ReadLine()); Console.WriteLi ne(); Num = new float[loopNum]; for (int i = 0; i < loopNum; i++) { Console.Write("Enter number: "); Num[i] = Convert.ToSingle(Console.ReadLine()); } for (int i = 0; i < loopNum; i++) { sum += Num[i]; Ave = sum / loopNum; } Console.ReadKey(); Console.Clear();

break; case 2:

Console.Write(" The sum of your numbers is {0}", sum); Console.ReadKey(); Console.Clear(); break; case 3: Console.Write(" The sum of your numbers is {0}", Ave); Console.ReadKey(); Console.Clear(); break; case 4: Console.Write("Do you want to exit (Type y or yes): "); string opt = Console.ReadLine().Trim(); if ((opt == "y") || (opt == "yes")) { check = true; } else Console.Write("Back to the Menu!"); Console.ReadKey(); Console.Clear(); break; default: Console.WriteLine(); Console.Write("Wrong input, Enter correct value"); Console.ReadKey(); Console.Clear(); break; } } while (check != true); } } } ________________________________________________________________________________ _________ LANGUAGE TRANSLATOR using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { bool check = false;

do { Console.Write("1..Translate to Frence"); Console.WriteLine(); Console.Write("2..Translate to German"); Console.WriteLine(); Console.Write("3..Translate to Spanish"); Console.WriteLine(); Console.Write("4..Translate to Swedish"); Console.WriteLine(); Console.Write("5..Exit"); Console.WriteLine(); Console.Write("ENter your name: "); string name = Console.ReadLine(); Console.Write(" Which is your language?(1-5)"); int opt = Convert.ToInt32(Console.ReadLine()); switch (opt) { case 1: Console.WriteLine(); Console.Write("Mon nom est {0}. J'aime les pommes", name ); Console.ReadKey(); Console.Clear(); break; case 2: Console.WriteLine(); Console.Write("Mein Name ist {0}. Ich liebe Äpfe", name); Console.ReadKey(); Console.Clear(); break; case 3: Console.WriteLine(); Console.Write("Mi nombre es {0}. Me encanta las manzanas ", name); Console.ReadKey(); Console.Clear(); break; case 4: Console.WriteLine(); Console.Write("Mitt namn är {0}. Jag älskar äpplen", name); Console.ReadKey(); Console.Clear(); break; case 5: Console.WriteLine("Are you sure you want to exit (press y to exit): "); string opt1 = Console.ReadLine().Trim(); if ((opt1 == "y") || (opt1 == "yes")) check = true; break; default: Console.WriteLine(); Console.Write("Wrong input enter number from 1-4"); Console.ReadKey(); Console.Clear(); break; }

} while (check != true); } } } ________________________________________________________________________________ _______________________ GAME (ARRAY CONCEPTS AND CASES) using using using using System; System.Collections.Generic; System.Linq; System.Text;

namespace ConsoleApplication1 { class Program { static void Main(string[] args) { string name = "Player1"; bool check = false; string[]guess = new string[5]; int i = 0; // array holding last scores int[] scores = new int[10]; do { Console.Write("1....Start Game"); Console.WriteLine(); Console.Write("2....View last scores"); Console.WriteLine(); Console.Write("3....Change Player's Name"); Console.WriteLine(); Console.Write("4....Exit"); Console.WriteLine(); Console.Write("Choose an option: "); int opt = Convert.ToInt32(Console.ReadLine().Trim()); switch (opt) { case 1: Console.Write("Hello {0} Lets play! Guess a number betwe en 1-100", name); Random r = new Random(DateTime.Now.Millisecond); int randnum = r.Next(1, 101); int[]num1= new int[10]; int[]num2 = new int[10]; int[]num3 = new int[10]; int[]num4 = new int[10];

int[]num5 = new int[10]; bool check1 = false, check2 = false, check3 = false, che ck4 = false, check5 = false; do { Console.Write(" Enter first guess: "); num1[i] = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); if ((num1[i] >= 1) && (num1[i] <= 100)) { check1 = true; } else { Console.Write("Invalid number range is 1-100, Re "); } } while (check1 != true); if (num1[i] == randnum) { Console.Write("Congrats you guessed the number!"); } else { if (num1[i] > randnum) { Console.Write("Your number is to big!"); } else { Console.Write("Your number is to small!"); } do { Console.Write(" Enter second guess: "); num2[i] = Convert.ToInt32(Console.ReadLine()); Console.WriteLine(); if ((num2[i] >= 1) && (num2[i] <= 100)) { check2 = true; } else { Console.Write("Invalid number range is 1-100 , Re"); } } while (check2 != true);

if (num2[1] == randnum) { Console.Write("Congrats you guessed the number!" ); } else { if (num2[i] > randnum) { Console.Write("Your number is to big!"); } else { Console.Write("Your number is to small!"); } do { Console.Write(" Enter third guess: "); num3[i] = Convert.ToInt32(Console.ReadLine() ); Console.WriteLine(); if ((num3[i] >= 1) && (num3[i] <= 100)) { check3 = true; } else { Console.Write("Invalid number range is 1 -100, Re"); } } while (check3 != true); if (num3[i] == randnum) { Console.Write("Congrats you guessed the numb er!"); } else { if (num3[i] > randnum) { Console.Write("Your number is to big!"); } else { Console.Write("Your number is to small!" ); }

do { Console.Write(" Enter fourth guess: "); num4[i] = Convert.ToInt32(Console.ReadLi ne()); Console.WriteLine(); if ((num4[i] >= 1) && (num4[i] <= 100)) { check4 = true; } else { Console.Write("Invalid number range is 1-100, Re"); } } while (check4 != true); if (num4[i] == randnum) { Console.Write("Congrats you guessed the number!"); } else { if (num4[i] > randnum) { Console.Write("Your number is to big !"); } else { Console.Write("Your number is to sma ll!"); } do { Console.Write(" Enter fifth guess: " ); num5[i] = Convert.ToInt32(Console.Re adLine()); Console.WriteLine(); if ((num5[i] >= 1) && (num5[i] <= 10 0)) { check5 = true; } else {

Console.Write("Invalid number ra nge is 1-100, Re"); } } while (check5 != true); if (num5[i] == randnum) { Console.Write("Congrats you guessed the number!"); } else { if (num5[i] > randnum) { Console.Write("Your number is to big!"); } else { Console.Write("Your number is to small!"); } Console.Write("You lost!"); Console.WriteLine(); Console.WriteLine(); Console.ReadKey(); Console.Clear(); } } } } } break; case 2: break; case 3: Console.Write("Enter your new name: "); name = Console.ReadLine(); break;

case 4: Console.Write("Do you want to exit? (y/Y): "); string opt1 = Console.ReadLine(); if ((opt1 == "y") || (opt1 == "Y")) { check = true; } else

{ Console.WriteLine("Please enter new option"); Console.ReadKey(); } break; default: Console.Write("Wrong input, Enter number from 1-4"); Console.ReadKey(); break; } } while (check != true); } } }

Sign up to vote on this title
UsefulNot useful