This is an assignment that i am doing for my class. Everything seem to work right expect for one code which for some reason is not outputting the account type.i am not getting any errors at all.I am input an char type not an number type. just does not seem to output the type of account for some reason

Assignment:

*
A bank updates t customers'' accounts at the end of each month. The bank offers two types of accounts: savings and checking. Every customer must maintain a minimum balance. If a customer's balance falls below the minimum balance, there is a service charge of $10.00 for savings accounts and $25.00 for checking accounts. If the balance at the end of the month is at least the minimum balance, the account receives interest as follows:

a) Savings accounts receive 4% interest.
b) Checking accounts with balances up to $5,000 more than the minimum balance receive 3% interest; otherwise, the interest is 5%.

write a program that reads a customers account number (char; S for savings, C for checking), minimum balance that the account should maintain, and current balance.The program should than output the account number,account type,current balance and interest earned and appropriate message . test your program by running five times , using the following data:


46728 S 1000 2700
87324 C 1500 7689
79873 S 1000 800
89832 C 2000 3000
98322 C 1000 750.
*/


The Code:

#include <iostream>
#include<fstream>
#include<iomanip>
using namespace std;
int main()
{
int accountNum;
char accountType;
char C,S;
float accountBalance;
double interest, minimumBalance;
cout<<"****** WELCOME ******"<<endl;
cout<<"Ready to update customer's accounts? Please Enter the following:"<<endl;
cout<<"Enter Account Number: "<<endl;
cin>> accountNum;
cout<<"Enter Account Type:"<<endl;
cout<<"C = Checking Account"<<endl;
cout<<"S = Saving Account"<<endl;
cin>> accountType;
cout<<"Enter minimum account Balance: "<<endl;
cin>> minimumBalance;
cout<<"Enter the Account Balance: "<<endl;
cin>> accountBalance;
if (accountType == 'S' && accountBalance< minimumBalance)
{
accountBalance= accountBalance - 10.00;
}

if (accountType == 'S' && accountBalance> minimumBalance)
{
interest= (accountBalance * 4)/100;
}
if (accountType== 'C' && accountBalance<minimumBalance )
{
accountBalance= accountBalance - 25.00;
}
if ( accountType == 'C' && accountBalance >= minimumBalance)
{
interest = (accountBalance * 5)/100;
}
if ( accountType= 'C' && accountBalance<= (minimumBalance + 5000.00) && accountBalance > minimumBalance)
{
interest = (accountBalance * 3)/100;
}
cout << fixed << showpoint << setprecision(2);
cout<<"Account Number: "<< accountNum<<endl;
cout<<" Account Type: "<< accountType<<endl;
cout<<"Account Balance: $"<< accountBalance<<endl;/
cout<<"The amount of Interest Earned: $"<< interest<<endl
cin.get();
return 0;
}

Recommended Answers

All 3 Replies

Works fine for me. Try printing the accountType immediately after you input it, to verify you got it.

Also, about 5 lines up from where you currently start your output, you have a typo which assigns 'C' to accountType instead of testing whether it's equal to 'C'.

In the future, please surround your code with code-tags, it preserves your formatting and numbers your lines so we can discuss your code more intelligently with you.

Works fine for me. Try printing the accountType immediately after you input it, to verify you got it.

Also, about 5 lines up from where you currently start your output, you have a typo which assigns 'C' to accountType instead of testing whether it's equal to 'C'.

In the future, please surround your code with code-tags, it preserves your formatting and numbers your lines so we can discuss your code more intelligently with you.

Sorry I am new to the website, how do I do that?

CODE TAGS
... read any of the requested information posted all over this site about CODE tags, like
1) in the Rules you were asked to read when you registered
2) in the text at the top of this forum
3) in the announcement at the top of this forum titled Please use BB Code and Inlinecode tags
4) in the sticky post above titled Read Me: Read This Before Posting
5) Even on the background of the box you actually typed your message in!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.