It-Tlieta, Jannar 22, 2008

C# IF - ELSE

namespace ConsoleApplication7
{
class Program
{/* 4EUR per hour till 40 hours
* 8EUR per hour after 40 hours
*/


static void Main(string[] args)
{

double totalHoursWorked, standardWage, overtimeWage, totalWage;
const int standardHours = 40;
const double normalRate = 4;
const double overtimeRate = normalRate * 2;
double overtimeHours;


Console.WriteLine("Enter Total Hours worked");
totalHoursWorked = Convert.ToDouble(Console.ReadLine());

if (totalHoursWorked > standardHours)
{

overtimeHours = totalHoursWorked - standardHours;
standardWage = standardHours * normalRate;
overtimeWage = overtimeHours * overtimeRate;
totalWage = standardWage + overtimeWage;


Console.WriteLine("Overtime wage: " + overtimeWage + " +");
Console.WriteLine("Standard wage: " + standardWage);
Console.WriteLine("Total Wage is: " + totalWage);


}

else
{
standardWage = standardHours * normalRate;
Console.WriteLine("Total Wage is: " + standardWage);
}

Console.ReadLine();
}
}
}

No comments: