June 30th, 2017, 04:09 PM
Just for info. The code does have a problem. Try entering a non-numeric value for the number of cars.
Have you covered stream errors yet?
June 30th, 2017, 03:46 PM
No. The maximum number is fixed at 20 - but the user enters the required number not greater than this. If the maximum is required to be more, then 20 can be changed to the required maximum number.
...
June 30th, 2017, 03:15 PM
The issue with arrays is that you have to declare their size at compile time - and with vectors you don't. So using an array you need to specify the maximum size as part of the code. In this case the...
June 30th, 2017, 02:10 PM
See the reply in post #3 re use of a vector.
June 30th, 2017, 11:37 AM
Have you come across the ternary ? operator yet?
double calculate_charges ( double h ) {
if ( h == 24 ) {
return 10.00;
}
June 30th, 2017, 11:25 AM
double chg = 3 + (( h - 3 ) *0.50);
return chg;
Why not just
return 3 + (( h - 3 ) * 0.50);
June 30th, 2017, 11:18 AM