-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
59 lines (53 loc) · 2.17 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Xml.Linq;
using ExercMetodosAbstratos2.Entities;
namespace ExercMetodosAbstratos2
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of tax payers: ");
int n = int.Parse(Console.ReadLine());
List<TaxPayer> lstTxPayer = new List<TaxPayer>();
for (int i = 1; i <= n; i++)
{
Console.WriteLine($"Tax payer #{i} data: ");
Console.Write("Individual or company (i / c)? ");
Char typeShape = char.Parse(Console.ReadLine().ToLower());
Console.Write("Name: ");
string name = Console.ReadLine();
Console.Write("Annual Income: ");
double annualIncome = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
if (typeShape == 'i')
{
Console.Write("Health expenditures: ");
double healthExpenditures = double.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
lstTxPayer.Add(new Individual(name, annualIncome, healthExpenditures));
}
else
{
Console.Write("Number of employees: ");
int employeeQtty = int.Parse(Console.ReadLine(), CultureInfo.InvariantCulture);
lstTxPayer.Add(new Company(name, annualIncome, employeeQtty));
}
}
Console.WriteLine();
Console.WriteLine("TAXES PAID:");
double totalTaxes = 0;
foreach (TaxPayer taxPayer in lstTxPayer)
{
double tax = taxPayer.Tax();
totalTaxes += taxPayer.Tax();
Console.WriteLine(taxPayer.Name
+ ": $"
+ tax.ToString("F2", CultureInfo.InvariantCulture));
}
Console.WriteLine();
Console.WriteLine("TOTAL TAXES: $" + totalTaxes.ToString("F2", CultureInfo.InvariantCulture));
Console.ReadLine();
}
}
}