CSharp · Console
using System;
using System.Collections;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
Console.WriteLine("Please enter a range?");
string range = Console.ReadLine();
string first = range.Split(',')[0];
string last = range.Split(',')[1];
int min = Int32.Parse(first);
int max = Int32.Parse(last);
ArrayList arraylist = new ArrayList();
Console.WriteLine("");
Console.WriteLine("Heres the Output");
Console.WriteLine("");
for (int i = min; i < max ; i++ )
{
bool hello = i % 3 == 0;
bool world = i % 5 == 0;
if (hello && world)
arraylist.Add("HelloWorld");
else if (hello)
arraylist.Add("Hello");
else if (world)
arraylist.Add("World");
else
arraylist.Add(i);
}
foreach (var item in arraylist)
{
Console.WriteLine(item.ToString()); //Console app prints out result part
}
//Summmary Time
Console.WriteLine("");
Console.WriteLine("Heres the Summary");
Console.WriteLine("");
Dictionary<string, int> counts = new Dictionary<string, int>() {
{ "HelloWorld", 0},
{ "Hello", 0},
{ "World", 0},
{ "integer", 0},
};
foreach (var item in arraylist)
{
counts["HelloWorld"] += 1;
counts["Hello"] += 1;
counts["World"] += 1;
counts["integer"] += 1;
}
Console.WriteLine("");
foreach (KeyValuePair<string, int> item in counts)
{
Console.WriteLine(item.Key.ToString() + ":" + item.Value.ToString());
}
Console.ReadLine();
}
}