-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise001.cs
More file actions
50 lines (45 loc) · 1.47 KB
/
Exercise001.cs
File metadata and controls
50 lines (45 loc) · 1.47 KB
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
using System;
using System.Collections.Generic;
using System.Reflection;
namespace TechReturners.Exercises
{
public class Exercise001
{
public static String CapitalizeWord(String word)
{
return word.Substring(0, 1).ToUpper() + word.Substring(1);
}
public static String GenerateInitials(String firstName, String lastName)
{
return firstName.Substring(0, 1) + "." + lastName.Substring(0, 1);
}
public static double AddVat(double originalPrice, double vatRate)
{
double vat = (originalPrice / 100) * vatRate;
return Math.Round(Convert.ToDouble(vat + originalPrice), 2);
}
public static String Reverse(String sentence)
{
char[] charArray = sentence.ToCharArray();
Array.Reverse(charArray);
return new string(charArray);
}
public static int CountLinuxUsers(List<User> users)
{
int counter = 0;
foreach (var user in users)
{
foreach (PropertyInfo prop in user.GetType().GetProperties())
{
{
if (prop.GetValue(user, null).ToString() == "Linux")
{
counter++;
}
}
}
}
return counter;
}
}
}