Looping y/n prompts properly

Hi, I've been working on this assignment for the past couple of days and am stumped. I'm having trouble with my loops, I want it to ask the same question when the user inputs y or Y and then to ask an alternate question if the input n or N. My code is instead prompting the user again after the first prompt but when I type "y" it jumps to the next statement rather than repeating.

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
 #include <iostream>
using namespace std;

class SavingsAccount
{
private:
	int dollars, cents;
	void normalize();
public:
	SavingsAccount();
	void makeDeposit(int, int);		 //Adds value to dollars and cents
	void makeWithdrawal(int, int);	 //Subtracts values to dollars and cents
	void showBalance();				 //Displays current balance in dollars and cents

};

SavingsAccount::SavingsAccount()	 //Default constructor
{
	dollars = cents = 0;
}


void SavingsAccount::makeDeposit(int dol, int cnt)
{
	dollars += dol;	//Adds deposit to the account
	cents += cnt;
	normalize();
}

void SavingsAccount::makeWithdrawal(int dol, int cnt)
{
	dollars -= dol;	//Subtracts withdrawal from account
	cents -= cnt;
	normalize();
}

void SavingsAccount::showBalance()
{
	cout << "The balance is " << dollars << " dollars and " << cents << " cents" << endl;
}

void SavingsAccount::normalize()			// Converts cents into dollars & cents
{
	if (cents < 0)
	{
		dollars--;
		cents += 100;
	}
	else
	{
		dollars = dollars + (cents / 100);
		cents = cents % 100;
	}
}



int main()
{
	SavingsAccount bank1;
	int  depositDollar=40, depositCents=25, withdrawDollar=10, withdrawCents=75;	//Variables to hold account, deposit, and withdrawal
	int startingCents, startingDollars;
	char option;

	cout << "Please input the initial dollars" << endl;                             //Prompt for starting amount in dollars and cents
	cin >> depositDollar;
	cout << "Please input the initial cents" << endl;
	cin >> depositCents;
	bank1.makeDeposit(depositDollar, depositCents);
	cout << "Would you like to make a deposit? Y or y for yes." << endl;            //Prompt for deposit
	cin >> option;
	while (option == 'Y' || 'y')
        {
        cout << "Please input the dollars to be deposited" << endl;
        cin >> depositDollar;
        cout << "Please input the cents to be deposited" << endl;
        cin >> depositCents;
        bank1.makeDeposit(depositDollar, depositCents);
        cout << "Would you like to make a deposit?" << endl;
        cin >> option;


        if (option == 'N' || 'n')
            {
            cout << "Would you like to make a withdrawal?" << endl;
            cin >> option;
            }

             else if (option == 'Y' || 'y')
            {
                cout << "Please input the dollars to be withdrawn" << endl;
                cin >> withdrawDollar;
                cout << "Please input the cents to be withdrawn" << endl;
                cin >> withdrawCents;
                bank1.makeWithdrawal(withdrawDollar, withdrawCents);
            }

        }


       bank1.showBalance();


	return 0;
}

This is the output I'm trying to get


Please input the initial dollars
402
Please input the initial cents
78
Would you like to
make a deposit? Y or y for yes
y
Please input the dollars to be deposited
35
Please input the cents to be deposited
67
Would you like to make a deposit? Y or y for yes
y
Please input the dollars to be deposited
35
Please input the cents to be deposited
67
Would you like to make a deposit? Y or y for yes
n
Would you like to make a withdrawal Y or y for yes
y
Please input the dollars to be withdrawn
28
Please input the cents to be withdrawn
08
Would you like to make a withdrawal Y or y for yes
y
Please input
the dollars to be withdrawn
75
Please input the cents to be withdrawn
78

and so on and so forth..
Line 72, 83, 89: These statements are defective. C++ does not support an implicit left hand side. You must specify the left hand side of all conditions. e.g.
 
while (option == 'Y' || option == 'y')


As you have it, the second term ('y') will always evaluate true.

ahh that flew right over my head. it works now, but I had to make a few other adjustments as well. Thank you.
Topic archived. No new replies allowed.