payment problem
Feb 25, 2017 at 12:40am UTC
Payment doubles when the months are even, If months are odd they triple
I have most of it, but it prints weirdly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#include <iostream>
using namespace std;
int main()
{
int max;
int payment=1;
cout<<"How many months?" ;
cin>>max;
for (int min=1; min<=max;min++){
if (min = 1){
cout<<"month " <<min<<" " <<payment<<endl;
min++;}
if ((min%2)==0)
payment=payment*2;
else //(i/2!=0)
payment=payment*3;
}
return 0;
}
Feb 25, 2017 at 12:45am UTC
Hi,
Line 16, there is an assignment operator instead of comparison operator which is giving you the weird output. There are still some logical errors which I hope you can solve now...
Topic archived. No new replies allowed.