-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShop_algorythm.cs
More file actions
executable file
·66 lines (53 loc) · 1.92 KB
/
Shop_algorythm.cs
File metadata and controls
executable file
·66 lines (53 loc) · 1.92 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
66
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Shop_Program
{
class Program
{
static void Main(string[] args)
{
//Input money value
double money = 0;
Console.WriteLine("Input how much money do you have.. ");
money = Convert.ToDouble(Console.ReadLine());
//Quantity of products
Console.WriteLine("Input quantity of products.. ");
int product_quantity = Convert.ToInt32(Console.ReadLine());
string product = " ";
int quantity = 0;
double price = 0;
double count = 0;
for (int i = 0; i < product_quantity; i++)
{
//Input products and count their summ
//Input name. String parameter
Console.WriteLine("Input what product do you wanna buy.. ");
product += Console.ReadLine() + " ";
//Input quantity. Int parameter
Console.WriteLine("Input quantity of product.. ");
quantity = Convert.ToInt32(Console.ReadLine());
//Input price. Double parameter
Console.WriteLine("Input price of product.. ");
price = Convert.ToDouble(Console.ReadLine());
//Counting summ
count += quantity * price;
}
//Calculating
double result = 0;
result = money - count;
if (result < 0)
{
Console.WriteLine("No enough money.. Sorry " + result);
}
else
{
Console.WriteLine("Your change is.. " + result);
Console.WriteLine("You will buy" + product);
}
Console.ReadLine();
}
}
}