Commit f46bfc8f authored by mary.zaqaryan's avatar mary.zaqaryan

Mary Zaqaryan Exercise_05_14 Version2

parent f585b2f5
......@@ -8,8 +8,8 @@ main()
int productNumber;
std::cin >> productNumber;
if (productNumber < 0) {
std::cerr << "Error 1: Number can't be negative.";
if (productNumber < 0 && productNumber > 5) {
std::cerr << "Error 1: Invalid product number";
return 1;
}
......@@ -21,40 +21,16 @@ main()
return 2;
}
switch (productNumber)
{
case 1:
{
sum += productAmount * 2.98;
break;
}
case 2:
{
sum += productAmount * 4.50;
break;
}
case 3:
{
sum += productAmount * 9.98;
break;
}
case 4:
{
sum += productAmount * 4.49;
break;
}
case 5:
{
sum += productAmount * 6.87;
break;
}
default:
{
std::cerr << "Error 3: There are only 5 products.";
return 3;
}
}
switch (productNumber) {
case 1: sum += productAmount * 2.98; break;
case 2: sum += productAmount * 4.50; break;
case 3: sum += productAmount * 9.98; break;
case 4: sum += productAmount * 4.49; break;
case 5: sum += productAmount * 6.87; break;
}
}
std::cout << "Sum: " << sum << std::endl;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment