int calculate_fee(int cost) {
int result;
if (cost <= 5000)
throw new NotInterestingGetAnotherArchitectError();
// or simply 'return 8*cost/100;'
// 8% of the first 5000.00$ of the cost of a building
result = 8*5000/100;
// remainder
cost = cost - 5000;
// 3% on the remainder if the remainder is less than or equal to 80000.00
if (cost <= 80000) {
result = result + 3*cost/100;
else // or 2 1/2 % on the remainder if the remainder is more than 80000.00$.
result = result + 2.5*cost/100;
return result;
}
int main () {
...
calculate_fee(...)
...
}
If you are experiencing a similar issue, please ask a related question
Title | # Comments | Views | Activity |
---|---|---|---|
How to Force Consistent Line Break Characters in Notepad++ versus Microsoft Notepad | 8 | 118 | |
eclipse luna javeEE perspecive missing | 5 | 110 | |
How to debug Angular JS in Visual Studio 2013 | 2 | 178 | |
Embarcadero C++ Builder XE10.1 Berlin red arrow Indicator | 2 | 36 |
Join the community of 500,000 technology professionals and ask your questions.