#include <iostream>
#include <string>
int main() {
const int first100 = 40;
const int next200 = 50;
const int beyond300 = 60;
std::string name;
int unitsConsumed, payment = 0;
std::cout << "Please enter your name" << std::endl;
std::cin >> name;
std::cout << "Please enter units consumed" << std::endl;
std::cin >> unitsConsumed;
if ( unitsConsumed <= 100 && unitsConsumed > 0 ) {
payment = first100 * unitsConsumed;
} else if (unitsConsumed > 100 && unitsConsumed <= 300 ) {
payment = next200 * unitsConsumed;
} else if (unitsConsumed > 300 ) {
payment = beyond300 * unitsConsumed;
} else {
std::cout << "Ammount can not be negative. Ending program..." << std::endl;
return 0;
}
std::cout << "Dear " << name << ",\nYou have consumed " << unitsConsumed << " units, which requires " << payment << " credits." << std::endl;
return 0;
}
Comments
Leave a comment