JunkieHF

Basic User Interface C#

Jul 12th, 2014
347
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.04 KB | None | 0 0
  1. //Program Header
  2. //Program Name: Basic User Interface
  3. //Programmer:
  4. //CIS 247, Week 1 Lab
  5. //Program Description: Gets user input and displays name, age, and gas mileage
  6.  
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12.  
  13. namespace CIS247_WK1_Lab
  14. {
  15.     class Program
  16.     {
  17.         static void Main(string[] args)
  18.         {
  19.  
  20.             ApplicationUtilitiesinternal.DisplayApplicationInformation();
  21.             ApplicationUtilitiesinternal.DisplayDivider("Press any key to start");
  22.             Console.ReadLine();
  23.             ApplicationUtilitiesinternal.DisplayDivider("Get Name");
  24.             Console.WriteLine("What is your name?");
  25.             string name = InputUtilities.GetInput("name");
  26.  
  27.             //Prompts user for their age
  28.             int age;
  29.                 ApplicationUtilitiesinternal.DisplayDivider("Get Age");
  30.                 Console.WriteLine("How old are you?");
  31.                 string getAge = InputUtilities.GetInput("Age");
  32.                 age = Int32.Parse(getAge);
  33.  
  34.             //Prompts user to enter their car's mile per gallon
  35.             double galMileage;
  36.             ApplicationUtilitiesinternal.DisplayDivider("Get MPG");
  37.             Console.WriteLine("What is your car's miles per gallon?");
  38.             string getGasMileage = InputUtilities.GetInput("gas mileage");
  39.             galMileage = double.Parse(getGasMileage);
  40.  
  41.             //Name, Age, and galMileage outputs to the screen
  42.             Console.WriteLine("Hello, " + name);
  43.             Console.WriteLine("Your age is " + age);
  44.             Console.WriteLine("Your car's miles per gallon is " + galMileage);
  45.             Console.ReadLine();
  46.             ApplicationUtilitiesinternal.TerminateApplication();
  47.         }
  48.  
  49.         class ApplicationUtilitiesinternal
  50.         {
  51.             public static void DisplayApplicationInformation()
  52.             {
  53.                 Console.WriteLine("Welcome to the Basic User Interface Program! [PRESS ENTER]");
  54.                 Console.ReadLine();
  55.                 Console.WriteLine("CIS247, Week 1 Lab");
  56.                 Console.WriteLine("Name: Junkie [PRESS ENTER]");
  57.                 Console.ReadLine();
  58.                 Console.WriteLine("This program accepts user input as string, then makes the appropriate data conversion");
  59.             }
  60.  
  61.             internal static void DisplayDivider(string outputTitle)
  62.             {
  63.                 Console.WriteLine("****************" + outputTitle + "****************");
  64.             }
  65.  
  66.             internal static void TerminateApplication()
  67.             {
  68.                 Console.WriteLine("Thank you for using the Basic User Interface Program. Press any key to exit.");
  69.                 Console.ReadLine();
  70.             }
  71.         }
  72.     }
  73.  
  74.     class InputUtilities
  75.     {
  76.         internal static string GetInput(string inputType)
  77.         {
  78.             Console.WriteLine("Enter your " + inputType);
  79.             string strInput = Console.ReadLine();
  80.             return strInput;
  81.         }
  82.  
  83.  
  84.     }
  85. }
Add Comment
Please, Sign In to add comment