I provided func that return value for month as per the conditions.
double calc(double u) { // u - count of units
if (u >= 200) {
return 0.5 * u;
}
else if (u >= 100 && u < 200) { // && - (and)
return 0.6 * u;
}
else if (u >= 50 && u < 100) {
return 0.7 * u;
}
else {
return 0.8 * u;
}
}
Example of test program
#include <iostream>
double calc(double u) { // u - count of units
if (u >= 200) {
return 0.5 * u;
}
else if (u >= 100 && u < 200) { // && - (and)
return 0.6 * u;
}
else if (u >= 50 && u < 100) {
return 0.7 * u;
}
else {
return 0.8 * u;
}
}
int main (){
double un = 60;
std::cout <<"sum = " << calc(un) << std::endl;
un = 40;
std::cout <<"sum = " << calc(un) << std::endl;
un = 150;
std::cout <<"sum = " << calc(un) << std::endl;
return 0;
}
Comments
Leave a comment