-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
83 lines (58 loc) · 2.35 KB
/
Form1.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
namespace VOID_METHODS1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//VOID METHODS
void SpeedFormula(int path, int time)
{
int speed = path / time;
MessageBox.Show($"Your Speed : {speed} km/s");
}
//CONTROLA
private void btnCalculate1_Click(object sender, EventArgs e)
{
SpeedFormula(int.Parse(textPath.Text), int.Parse(textTime.Text));
}
//OVERLOAD METHODS
void Membership(DateTime startingdate, DateTime end_date)
{
if (startingdate == end_date)
{
MessageBox.Show("The dates should not be the same.");
}
else
{
TimeSpan membershipdays = end_date.Subtract(startingdate);
MessageBox.Show($"{textFullName.Text} Welcome\nTotal subscription time : {membershipdays.Days} days");
}
}
void Membership(DateTime startingdate, DateTime end_date, DateTime nowdate)
{
TimeSpan membershipdays = end_date.Subtract(startingdate);
TimeSpan remaining_time = nowdate.Subtract(startingdate);
MessageBox.Show($"{textFullName.Text} Welcome\nTotal subscription time : {membershipdays.Days} days\nRemaining day = {remaining_time.Days}");
}
//CONTROLA
private void btnCalculate2_Click(object sender, EventArgs e)
{
Membership(DateTime.Parse(textStartingdate.Text), DateTime.Parse(textEndDATE.Text), DateTime.Parse(textNowDate.Text));
}
//USING OUT IN METHODS
void DiscountAccount(double oldprice, double newprice, out double discountamount, out double percent)
{
discountamount = oldprice - newprice;
percent = (discountamount / oldprice) * 100;
}
private void btnCalculate3_Click(object sender, EventArgs e)
{
double discountamount;
double percent;
DiscountAccount(double.Parse(textOldprice.Text), double.Parse(textNewprice.Text), out discountamount, out percent);
MessageBox.Show($"Discount difference to the product: {(Math.Round(discountamount, 2))} TL\nPercentage of discount on the product: {(Math.Round(percent))} %");
}
}
}