Write the following program using C++ code. 1. Declares a string variable bankNa
ID: 3664674 • Letter: W
Question
Write the following program using C++ code.
1. Declares a string variable bankName and initializes it to Bank of California
2. Declares a string variable firstName
3. Declares a string variable lastName
4. Declares a float variable balance
5. Declares a float variable interest and initializes it to 8.8
6. Declares a named literal YEAR, whose value is 2016
7. Prompts the user for first name and saves the input in firstName
8. Prompts the user for last name and saves the input in lastName
9. Prompts the user for balance amount and saves the input in balance
10. Displays:
Hello firstName lastName, Welcome to bankName
You currently have $balance in your account.
The interest rate for YEAR is interest%.
Explanation / Answer
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string bankName, firstName, lastName;
float balance,interest;
int YEAR=2016;
interest=8.8;
bankName="Bank of California";
cout << "Please enter the First Name: ";
cin >> firstName;
cout << "Please enter the Last Name: ";
cin >> lastName;
cout << "Please enter the Balance: ";
cin >> balance;
cout << "Hello "<< firstName <<" "<< lastName <<", Welcome to " << bankName;
cout << " You currently have " << balance << " in your account.";
cout << " The interest rate for " << YEAR <<" is " << interest << ".";
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.