* Dec 10, 17
* Projected Raises */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectedRaises
{
class Program
{
static void Main(string[] args)
{
//Declarations
bool programSelectError = false, Menu = true;
int programSelect;
ConsoleKeyInfo kb;
while (Menu)
{
Console.Clear(); Console.Title = "Main Menu";
//Main Menu
Console.WriteLine("Programs:");
Console.WriteLine(" 1. Projected Raises \n 2. Projected Raises Interactive \n\n Q. Quit");
if (programSelectError) //Invalid Selection
{
Console.WriteLine("\nThat is not a Valid Choice, Enter # 1-2 or Q to Quit");
programSelectError = false;
}
Console.Write("\nPlease Select the Program you would like to run: ");
kb = Console.ReadKey(); //Listens for Key
if (kb.Key == ConsoleKey.Q)
{
Menu = false;
}
string programKey = kb.KeyChar.ToString();
Int32.TryParse(programKey, out programSelect);
switch (programSelect) //Program Selection
{
case 1: Menu = false; NonInteractive(); break;
case 2: Menu = false; Interactive(); break;
default: programSelectError = true; break;
}
}
}
static void NonInteractive()
{
Console.Clear(); Console.Title = "Projected Raises";
//Declarations
const double raisePercent = .04;
string[] employee = new string[3] { "Ray", "Rick", "David" };
double[] currentSalary = new double[3] { 55243, 56383, 57542 };
double[] nextYearsSalary = new double[3];
//Open Statement
Console.WriteLine("This program calculates projected raises based on a {0}% raise\n", (raisePercent * 100));
for (int i = 0; i < employee.Length; i++)
{
//Calculations
nextYearsSalary[i] = currentSalary[i] * (1 + raisePercent);
//Output
Console.WriteLine("{0}’s current salary is {1:C}", employee[i], currentSalary[i]);
Console.WriteLine("{0}’s projected salary next year is {1:C}\n", employee[i], nextYearsSalary[i]);
}
Console.WriteLine("Press any key to Exit"); Console.ReadKey();
}
static void Interactive()
{
Console.Clear(); Console.Title = "Projected Raises Interactive";
//Declarations
const double raisePercent = .04;
string[] employee = new string[3] { "Ray", "Rick", "David" };
double[] currentSalary = new double[3];
double[] nextYearsSalary = new double[3];
//Open Statement
Console.WriteLine("This program calculates projected raises based on a {0}% raise\n", (raisePercent * 100));
for (int i = 0; i < employee.Length; i++)
{
Console.Write("Please Enter {0}’s Current Salary: ", employee[i]);
while (!Double.TryParse(Console.ReadLine(), out currentSalary[i]))
{
Console.WriteLine("That is not number…\n");
Console.Write("Please Enter {0}’s Current Salary: ", employee[i]);
}
}
Console.WriteLine();
for (int i = 0; i < employee.Length; i++)
{
//Calculations
nextYearsSalary[i] = currentSalary[i] * (1 + raisePercent);
//Output
Console.WriteLine("{0}’s projected salary next year is {1:C}\n", employee[i], nextYearsSalary[i]);
}
Console.WriteLine("Press any key to Exit"); Console.ReadKey();
}
}
}
[/code]