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;
- using System.Windows.Forms;
- namespace Ch6Prg1
- {
- class Ch6Prg1
- {
- static void Main(string[] args)
- {
- Header();
- // these are my integers for the values that will be generated
- int minimumValue = 1000;
- int maximumValue = 0;
- int numEvens = 0;
- Random num = new Random(); // this line refers to the random number
- string result = "";
- for (int i = 1; i <= 100; i++ )
- {
- // in this loop, the if statements allow for random numbers to
- // be generated based on calculations and checking to see
- // the values of previous generated numbers
- int RandomNumber = num.Next(1, 1001);
- int evenRem = RandomNumber % 2;
- if (evenRem == 0)
- {
- numEvens++;
- }
- if (RandomNumber <= minimumValue)
- {
- minimumValue = RandomNumber;
- }
- if (RandomNumber >= maximumValue)
- {
- maximumValue = RandomNumber;
- }
- // this allows for the result to be developed
- result += i + "." + RandomNumber + "\t\t";
- }
- int range = maximumValue - minimumValue;
- // this string below concatinates all of the generated values
- string total = "Number of Evens: \t" + numEvens
- + "\nSmallest number: \t" + minimumValue
- + "\nLargest number: \t" + maximumValue + "\nRange: \t" + range;
- MessageBox.Show(result + total, "Random Numbers");
- // kyle and leon showed me how to use Windows Forms in order to
- // display the generated numbers in a message box, thx guys
- Footer();
- }
- public static void Footer()
- {
- Console.WriteLine("Please hit any key to continue");
- Console.ReadKey();
- }
- public static void Header()
- {
- // hey this is my header its pretty neat
- Console.SetWindowSize(100, 60);
- Console.ForegroundColor = ConsoleColor.Red;
- Console.WriteLine(@" Author:
- ▄█ ▄██████▄ ▄████████ ▄████████ ███ █▄ ▄████████ ▄████████ ▄██████▄
- ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███ ███
- ███ ███ ███ ███ █▀ ███ ███ ███ ███ ███ █▀ ███ █▀ ███ ███
- ███ ███ ███ ▄███▄▄▄ ▄███▄▄▄▄██▀ ███ ███ ███ ███ ███ ███
- ███ ███ ███ ▀▀███▀▀▀ ▀▀███▀▀▀▀▀ ███ ███ ▀███████████ ▀███████████ ███ ███
- ███ ███ ███ ███ █▄ ▀███████████ ███ ███ ███ ███ ███ ███
- ███ ███ ███ ███ ███ ███ ███ ███ ███ ▄█ ███ ▄█ ███ ███ ███
- █▄ ▄███ ▀██████▀ ██████████ ███ ███ ████████▀ ▄████████▀ ▄████████▀ ▀██████▀
- ▀▀▀▀▀▀ ███ ███
- ");
- Console.ForegroundColor = ConsoleColor.Cyan;
- Console.WriteLine(" \t Title: Chapter 10 Program 1 \n");
- Console.WriteLine(" \t Date: 5/23/18");
- Console.WriteLine(" \t Purpose: To demonstrate usage of loops");
- Console.WriteLine(" \t \t in order to generate a number \n");
- Console.WriteLine("-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-\n");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement