Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.ComponentModel;
- using System.Reflection.Emit;
- public class Employee
- {
- public String name;
- public double hourlyWage;
- public double hoursPerDay;
- public double daysPerMonth;
- public Employee(String name, double hourlyWage, double hoursPerDay, double daysPerMonth)
- {
- this.name = name;
- this.hourlyWage = hourlyWage;
- this.hoursPerDay = hoursPerDay;
- this.daysPerMonth = daysPerMonth;
- }
- public double CalculateMonthlySalary()
- {
- return (hourlyWage * hoursPerDay) * daysPerMonth;
- }
- public double CalculateAnnualSalary()
- {
- return ((hourlyWage * hoursPerDay) * daysPerMonth) * 12;
- }
- public void DisplayInfo()
- {
- Console.WriteLine($"------------------------------\nEmployee Name: {name}");
- Console.WriteLine($"Hourly Wage: {hourlyWage}\nHours Per Day: {hoursPerDay}\nDays Per Month: {daysPerMonth}");
- double monthlysalary = CalculateMonthlySalary();
- Console.WriteLine($"{name}'s Salary per month is PHP{monthlysalary}");
- double annualsalary = CalculateAnnualSalary();
- Console.WriteLine($"{name}'s Salary per year is PHP{annualsalary}\n------------------------------");
- }
- }
- public class program
- {
- public static void Main(String[] args)
- {
- Console.WriteLine("Enter the number of Employees: ");
- int NumEmployee = int.Parse(Console.ReadLine());
- Employee[] employee = new Employee[NumEmployee];
- for (int i = 0; i < NumEmployee;i++) {
- string Name;
- double HourlyWage;
- double HoursPerDay;
- double DaysPerMonth;
- bool valid = false;
- Console.WriteLine($"Enter Employee #{i+1} name");
- Name = Console.ReadLine();
- repeat:
- Console.Write("Enter Hourly Wage: ");
- if (!double.TryParse(Console.ReadLine(), out HourlyWage))
- {
- bumalik:
- Console.WriteLine("Invalid input!, Continue or Re-enter? (c / r)");
- string input = Console.ReadLine();
- switch (input.ToLower())
- {
- case "c":
- break;
- case "r":
- goto repeat;
- break;
- default:
- Console.WriteLine("Invalid input!");
- goto bumalik;
- break;
- }
- }
- repeat1:
- Console.Write("Enter Hours Per Day: ");
- if (!double.TryParse(Console.ReadLine(), out HoursPerDay))
- {
- bumalik:
- Console.WriteLine("Invalid input!, Continue or Re-enter? (c / r)");
- string input = Console.ReadLine();
- switch (input.ToLower())
- {
- case "c":
- break;
- case "r":
- goto repeat1;
- default:
- Console.WriteLine("Invalid input!");
- goto bumalik;
- }
- }
- repeat2:
- Console.Write("Enter Days Per Month: ");
- if (!double.TryParse(Console.ReadLine(), out DaysPerMonth))
- {
- bumalik:
- Console.WriteLine("Invalid input!, Continue or Re-enter? (c / r)");
- string input = Console.ReadLine();
- switch (input.ToLower())
- {
- case "c":
- break;
- case "r":
- goto repeat2;
- default:
- Console.WriteLine("Invalid input!");
- goto bumalik;
- }
- }
- employee[i] = new Employee(Name,HourlyWage,HoursPerDay,DaysPerMonth);
- }
- for(int i=0;i<NumEmployee;i++)
- {
- employee[i].DisplayInfo();
- }
- }
- }
Add Comment
Please, Sign In to add comment