Question: In C++: Create a second version of this program that uses nested if statements instead of a Switch construct. The outputs must be identical. #include

In C++: Create a second version of this program that uses nested if statements instead of a Switch construct. The outputs must be identical.
#include
using namespace std;
int main()
{
int accNumber;
double initial_balance;
double amount;
char type;
cout.setf(ios::fixed);
cout.setf(ios::left);
cout.precision(2);
cout<<"Enter the account number: ";
cin>>accNumber;
cout<<"Enter the initial balance: $";
cin>>initial_balance;
int temp=0;
do{
cout<<" SAVINGS ACCOUNT TRANSACTION";
cout<<" (W)ithdrawal";
cout<<" (D)eposit";
cout<<" (Z) to end account transaction";
cout<<" Enter the first letter of transaction type (W, D or Z): ";
cin>>type;
switch(type){
case 'W':
case 'w':{
cout<<"Amount: $";
cin>>amount;
initial_balance-=amount;
cout<<"Balance for this account is now: $"<
break;
}
case 'D':
case 'd':{
cout<<"Amount: $";
cin>>amount;
initial_balance+=amount;
cout<<"Balance for this account is now: $"<
break;
}
case 'z':
case 'Z':{
cout<<"No more changes.";
cout<<" Balance for this account is now: $"<
cout<<" Press any key to continue ...";
temp++;
break;
}
default: break;
}
}while(temp==0);
return 0;
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!