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

Mary Zaqaryan Exercise_05_14 Version2

parent 5e3183af
#include <iostream>
int
main()
{
double sum = 0;
for (int i = 0; i < 5; ++i) {
int productNumber;
std::cin >> productNumber;
if (productNumber < 0) {
std::cerr << "Error 1: Number can't be negative.";
return 1;
}
int productAmount;
std::cin >> productAmount;
if (productAmount < 0) {
std::cerr << "Error 2: Amount can't be negative.";
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;
}
}
}
std::cout << "Sum: " << sum << std::endl;
}
exercise_05_14: exercise_05_14.o | .gitignore
g++ $^ -o $@
exercise_05_14.ii: exercise_05_14.cpp
g++ -E $^ -o $@
exercise_05_14.s: exercise_05_14.ii
g++ -S $^ -o $@
exercise_05_14.o: exercise_05_14.s
g++ -c $^ -o $@
.gitignore:
echo "exercise_05_14" > $@
removes:
rm *.ii *.s *.o *.out exercise_05_14 .gitignore
test: exercise_05_14
./exercise_05_14 < test.in > test.out
diff test.out test.expected > /dev/null 2>&1 && echo PASSED || echo FAILED
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