value inputString valid true else value Invalid input valid false if valid

Value inputstring valid true else value invalid input

This preview shows page 2 - 4 out of 5 pages.

value = inputString; valid = true; } else { value = "Invalid input"; valid = false; } if (!valid) Console.WriteLine("Invalid " + inputType + " try again!"); } while (!valid); return value; } public static int getIntegerInputValue(string inputType) { bool valid = false; int value = 0; string inputString = String.Empty; do { inputString = GetInput(inputType); if (!(String.IsNullOrEmpty(inputString))) { valid = Int32.TryParse(inputString, out value); } if (!valid) Console.WriteLine("Invalid " + inputType + " try again!"); } while (!valid); return value; } public static double getDoubleInputValue(string inputType) { bool valid = false; double value = 0; string inputString = String.Empty; do { inputString = GetInput(inputType); if (!(String.IsNullOrEmpty(inputString))) { valid = Double.TryParse(inputString, out value); } if (!valid) Console.WriteLine("Invalid " + inputType + " try again!"); } while (!valid); return value; } public static char getCharInputValue(string inputType) { bool valid = false; char value = 'u'; string inputString = String.Empty; do
Image of page 2
{ inputString = GetInput(inputType); if (!(String.IsNullOrEmpty(inputString))) { valid = Char.TryParse(inputString, out value); } if (!valid) Console.WriteLine("Invalid " + inputType + " try again!"); } while (!valid); return value; } } } PROGRAM.CS- using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Employee { class Program { static void Main(string[] args) { ApplicationUtilities.DisplayApplicationInformation(); ApplicationUtilities.DisplayDivider("Start Program"); ApplicationUtilities.DisplayDivider("Prompt for Employee information and create first employee"); Employee employee1 = new Employee(); employee1.firstName = InputUtilities.getStringInputValue("First Name"); employee1.lastName = InputUtilities.getStringInputValue("Last Name"); employee1.gender = InputUtilities.getCharInputValue("Gender");
Image of page 3
Image of page 4

You've reached the end of your free preview.

Want to read all 5 pages?

  • Fall '14
  • Subroutine, Return statement, Void type, public Employee, string inputType

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture