Advertisement
Guest User

TestProject

a guest
Sep 14th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.17 KB | None | 0 0
  1. using System;
  2. using System.Timers;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace TestingProject
  9. {
  10.     class Program
  11.     {
  12.         public static string ID, Password, Answer;
  13.         public static int Error = 3;
  14.         static void Main()
  15.         {
  16.             Console.WriteLine("_______________________________________________________________________________________________");
  17.             Console.WriteLine("|                                                                                             |");
  18.             Console.WriteLine("|Available Programs: All, BinaryConversion, LoginAttempt, NumberTriangle, NameandSum, Counter.|");
  19.             Console.WriteLine("|_____________________________________________________________________________________________|");
  20.             Console.Write("Choose a program: ");
  21.             Answer = Console.ReadLine();
  22.             if (Answer == "All")
  23.             {
  24.                 GetIDandPass();
  25.                 Console.WriteLine();
  26.                 BinaryConversion();
  27.                 Console.WriteLine();
  28.                 NumberTriangle();
  29.                 Console.WriteLine();
  30.                 NameandSum();
  31.                 Console.WriteLine();
  32.                 Reset();
  33.             }
  34.             if (Answer == "BinaryConversion")
  35.             {
  36.                 BinaryConversion();
  37.                 Console.WriteLine();
  38.                 Reset();
  39.             }
  40.             if (Answer == "LoginAttempt")
  41.             {
  42.                 GetIDandPass();
  43.                 Console.WriteLine();
  44.                 Reset();
  45.             }
  46.             if (Answer == "NumberTriangle")
  47.             {
  48.                 NumberTriangle();
  49.                 Console.WriteLine();
  50.                 Reset();
  51.             }
  52.             if (Answer == "NameandSum")
  53.             {
  54.                 NameandSum();
  55.                 Console.WriteLine();
  56.                 Reset();
  57.             }
  58.             if (Answer == "Counter")
  59.             {
  60.                 Counter();
  61.                 Console.WriteLine();
  62.                 Reset();
  63.             }
  64.         }
  65.  
  66.         static void LoginAttempt()
  67.         {
  68.             Console.Write("Please login with the format <username> <password>: ");
  69.             string Login = Console.ReadLine();
  70.             if (Login != ID + " " + Password)
  71.             {
  72.                 if (Error >= 1)
  73.                 {
  74.                     Console.Clear();
  75.                     Console.WriteLine("Please try again. You have " + (Error - 1) + " tries left.");
  76.                     Error -= 1;
  77.                 }
  78.                 if (Error < 1)
  79.                 {
  80.                     Console.WriteLine("Terminating Command Window.");
  81.                     Environment.Exit(0);
  82.                 }
  83.                 LoginAttempt();
  84.             }
  85.             if (Login == ID + " " + Password)
  86.             {
  87.                 Console.WriteLine("Welcome, " + ID);
  88.             }
  89.         }
  90.         static void NumberTriangle()
  91.         {
  92.             Console.Write("Enter a number that is less than 15: ");
  93.             int PastaNum = Convert.ToInt32(Console.ReadLine());
  94.             Console.Write("Enter the width that is less than 15: ");
  95.             int width = Convert.ToInt32(Console.ReadLine());
  96.             if (PastaNum < 15 && width < 15)
  97.             {
  98.                 int height = width;
  99.                 for (int row = 0; row < height; row++)
  100.                 {
  101.                     for (int column = 0; column < width; column++)
  102.                     {
  103.                         Console.Write(PastaNum);
  104.                     }
  105.                     Console.WriteLine();
  106.                     for (int spacer = 0; spacer < width; spacer++)
  107.                     {
  108.                         Console.Write("~");
  109.                     }
  110.                     Console.WriteLine();
  111.                     width--;
  112.                 }
  113.             } else
  114.             {
  115.                 Console.WriteLine("Please use smaller numbers.");
  116.                 NumberTriangle();
  117.             }
  118.         }
  119.         static void NameandSum()
  120.         {
  121.             Console.Write("Please enter your first name: ");
  122.             string FirstName = Console.ReadLine();
  123.             Console.Write("Please enter your last name: ");
  124.             string LastName = Console.ReadLine();
  125.             Console.Write("Enter a number: ");
  126.             string NumOne = Console.ReadLine();
  127.             long NumOne64Bit = Convert.ToInt64(NumOne);
  128.             Console.Write("Enter another number: ");
  129.             string NumTwo = Console.ReadLine();
  130.             long NumTwo64Bit = Convert.ToInt64(NumTwo);
  131.             long Sum64 = NumOne64Bit + NumTwo64Bit;
  132.             string YourSum = ("The sum of " + NumOne + " and " + NumTwo + " is: " + Sum64 + ". Good job " + FirstName + " " + LastName + "!");
  133.             Console.WriteLine(YourSum);
  134.         }
  135.         static void BinaryConversion()
  136.         {
  137.             Console.Write("Enter a big number: ");
  138.             int Num = Convert.ToInt32(Console.ReadLine());
  139.             string Result = "";
  140.             while (Num >1)
  141.             {
  142.                 int Remainder = Num % 2;
  143.                 Result = Convert.ToString(Remainder) + Result;
  144.                 Num /= 2;
  145.             }
  146.             Result = Convert.ToString(Num) + Result;
  147.             Console.WriteLine("Binary: {0}", Result);
  148.         }
  149.         static void GetIDandPass()
  150.         {
  151.             Console.Write("Please enter your username: ");
  152.             ID = Console.ReadLine();
  153.             Console.Write("Pleas enter your password: ");
  154.             Password = Console.ReadLine();
  155.             LoginAttempt();
  156.         }
  157.         static void Reset()
  158.         {
  159.             Answer = null;
  160.             Main();
  161.         }
  162.         static void Counter()
  163.         {
  164.             Console.Write("Please enter a number: ");
  165.             int Num = Convert.ToInt32(Console.ReadLine());
  166.             Console.WriteLine();
  167.             Console.Write("|  " + Num + "  |  ");
  168.             for (int i = 0; i < 10; i++)
  169.             {
  170.                 System.Threading.Thread.Sleep(500);
  171.                 Console.Write((Num *= 2) + "  |  ");
  172.             }
  173.         }
  174.     }
  175. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement