-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtipCalculator.cs
More file actions
27 lines (24 loc) · 884 Bytes
/
Copy pathtipCalculator.cs
File metadata and controls
27 lines (24 loc) · 884 Bytes
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace tipCalculator
{
class Program
{
static void Main(string[] args)
{
CalculateTip(120, "great");
}
public static int CalculateTip(double amount, string rating)
{
if (rating.ToLower() == "terrible") return 0;
else if (rating.ToLower() == "poor") return Convert.ToInt32(Math.Ceiling(amount * 5 / 100));
else if (rating.ToLower() == "good") return Convert.ToInt32(Math.Ceiling(amount * 10 / 100));
else if (rating.ToLower() == "great") return Convert.ToInt32(Math.Ceiling(amount * 15 / 100));
else if (rating.ToLower() == "excellent") return Convert.ToInt32(Math.Ceiling(amount * 20 / 100));
else return -1;
}
}
}