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 Weekly_Pay_Calculator
- {
- class ApplicationUtilities
- {
- //Displays information
- public static void DisplayApplicationInformation()
- {
- Console.WriteLine("Welcome to the Weekly Pay Calculator! [PRESS ENTER]");
- Console.ReadLine();
- Console.WriteLine("Programmer: Junkie [PRESS ENTER]");
- Console.ReadLine();
- Console.WriteLine("This program gets hours worked from user and calculates weekly pay. The employee receives $7.50 per hour for the first 40 hours and $11.25 per hour for each additional hour. ");
- }
- //Divider
- internal static void DisplayDivider(string outputTitle)
- {
- Console.WriteLine("****************" + outputTitle + "****************");
- }
- //The program ends here
- internal static void TerminateApplication()
- {
- Console.WriteLine("Thank you for using the Weekly Pay Calculator. Press the ENTER key to exit.");
- Console.ReadLine();
- }
- }
- }
- //New Class Starts Here
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Weekly_Pay_Calculator
- {
- class InputUtilities
- {
- public static string GetInput(string inputType) //declaring GetInput
- {
- string strInput = String.Empty;
- Console.Write("Enter your " + inputType + ": ");
- strInput = Console.ReadLine();
- return strInput;
- }
- public static double getDoubleInputValue(string inputType) //makes sure user inputs a double
- {
- 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!"); //if not a double
- } while (!valid);
- return value;
- }
- }
- }
- //New Class Starts Here
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Weekly_Pay_Calculator
- {
- class Program
- {
- static void Main(string[] args)
- {
- ApplicationUtilities.DisplayApplicationInformation(); //Displays Program Information
- ApplicationUtilities.DisplayDivider("START PROGRAM");
- Console.WriteLine("Press [ENTER] to Begin");
- Console.ReadLine();
- ApplicationUtilities.DisplayDivider("PROMPT FOR Hours Worked And Overtime"); //in the below lines we are asking the user how many hours they have worked
- Console.WriteLine("How many regular hours did you work?");
- double hoursWorked = InputUtilities.getDoubleInputValue("Regular Time Worked");
- Console.WriteLine("How many overtime hours did you work?");
- double overtime = InputUtilities.getDoubleInputValue("Overtime worked");
- double weeklyPay = hoursWorked * 7.50;
- double overtimePay = overtime * 11.25;
- double totalPay = weeklyPay + overtimePay;
- Console.WriteLine("You have earned the following amount for your regular hours: " + weeklyPay); //displays amount earned for reg hours
- Console.WriteLine("Press ENTER");
- Console.ReadLine();
- Console.WriteLine("You have earned the following amount in overtime: " + overtimePay); //overtime earnings
- Console.WriteLine("Press Enter");
- Console.ReadLine();
- Console.WriteLine("Your total earnings for this week is: " + totalPay); //total earnings
- Console.WriteLine("Press Enter");
- Console.ReadLine();
- ApplicationUtilities.TerminateApplication(); //Exits the application
- }
- }
- }
Add Comment
Please, Sign In to add comment