Skip to content

Instantly share code, notes, and snippets.

@bpmct
Created February 12, 2020 02:09
Show Gist options
  • Save bpmct/b0703388ee2dfee2d4a340a8b87bfad6 to your computer and use it in GitHub Desktop.
Save bpmct/b0703388ee2dfee2d4a340a8b87bfad6 to your computer and use it in GitHub Desktop.
using System;
namespace Salary
{
class Program
{
//struct employee
//{
//public string sName;
// public double dSalary;
//}
//And rewrite the GiveRaise() function to pass the struct as the only parameter
struct employee
{
public string sName;
public double dSalary;
}
static void Main(string[] args)
{
employee thisEmployee;
thisEmployee.dSalary = 3000;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("Please enter your name: ");
Console.ForegroundColor = ConsoleColor.Gray;
thisEmployee.sName = Console.ReadLine();
//Make it lowercase
thisEmployee.sName = thisEmployee.sName.ToLower();
Console.WriteLine($"Hi {thisEmployee.sName} here is your salary: ${thisEmployee.dSalary}");
GiveRaise(thisEmployee);
Console.ReadLine();
}
static bool GiveRaise(employee theEmployee)
{
string myName = "ben";
double newSalary = 19999.99;
if (theEmployee.sName == myName)
{
theEmployee.dSalary += newSalary;
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine($"Congrats for having the same name as me! Here is your new salary: {theEmployee.dSalary}");
return true;
}
return false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment