forked from EllieJudge/c_sharp_coding_exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise001.cs
More file actions
65 lines (59 loc) · 1.73 KB
/
Exercise001.cs
File metadata and controls
65 lines (59 loc) · 1.73 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
namespace TechReturners.Exercises
{
public class Exercise001
{
public static String CapitalizeWord(String word)
{
if (word.Length > 0)
{
return char.ToUpper(word[0]) + word.Substring(1);
}
else
{
return "";
}
}
public static String GenerateInitials(String firstName, String lastName)
{
var initials = "";
if(firstName.Length > 0)
{
char first = firstName[0];
initials = first.ToString() + ".";
}
if (lastName.Length > 0)
{
char last = lastName[0];
initials += last.ToString();
}
return initials.ToUpper();
}
public static double AddVat(double originalPrice, double vatRate)
{
double vat = (vatRate + 100) / 100;
double totalprice = originalPrice * vat;
return Math.Round(totalprice,2);
}
public static String Reverse(String sentence)
{
char[] arrsentence = sentence.ToCharArray();
Array.Reverse(arrsentence);
return new string(arrsentence);
}
public static int CountLinuxUsers(List<User> users)
{
int oscount = 0;
for(int i=0; i<users.Count; i++)
{
var user = users[i];
if(user.Type == "Linux")
{
oscount += 1;
}
}
return oscount;
}
}
}