Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Assignment_3
- {
- class Program
- {
- static void Exercise1()
- {
- int min;
- int max;
- var list = new List<int>();
- var sum = list.Sum();
- Console.WriteLine("Enter minimum integer: ");
- min = int.Parse(Console.ReadLine());
- Console.WriteLine("Enter maximum integer: ");
- max = int.Parse(Console.ReadLine());
- while (min <= max && max >= min)
- {
- Console.WriteLine(min);
- min++;
- list.Sum(str => Convert.ToInt32(min));
- }
- }
- static void Exercise2()
- {
- string entry;
- Console.Write("Enter an integer or 'q' to quit ");
- entry = Console.ReadLine();
- while (entry.ToLower() != "q")
- {
- int number;
- if (int.TryParse(entry, out number))
- {
- if (number >= 1 && number <= 10)
- {
- Dictionary<string, Int32> dictionary = new Dictionary<string, Int32>();
- dictionary.Add("1", 1);
- dictionary.Add("2", 2);
- dictionary.Add("3", 3);
- dictionary.Add("4", 4);
- dictionary.Add("5", 5);
- dictionary.Add("6", 6);
- dictionary.Add("7", 7);
- dictionary.Add("8", 8);
- dictionary.Add("9", 9);
- dictionary.Add("10", 10);
- foreach (KeyValuePair<string, int> kvp in dictionary)
- {
- Console.WriteLine("Key = {0}, Value = {1}", kvp.Key, kvp.Value);
- }
- }
- else
- {
- Console.WriteLine("Your number must be between 1 and 10");
- }
- }
- Console.Write("Enter an integer or 'q' to quit ");
- entry = Console.ReadLine();
- }
- }
- static void Main(string[] args)
- {
- Exercise1();
- Exercise2();
- Console.WriteLine("Press enter to end");
- Console.ReadLine();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement