Question: - This is C++ code, I need help with fixing errors attached at end of code. // bring in our libraries #include #include #include #include
- This is C++ code, I need help with fixing errors attached at end of code. // bring in our libraries
#include
using namespace std;
/// Entry point to the application
int main() {
// pause cout
}
//create constant values -- cannot be changed
const int EXIT_VALUE = 5; const float DAILY_LIMIT = 400.0f; const string FILENAME = "Account.txt";
// create balance variable double balance = 0.0;
// look for the starting balance; otherwise generate a random starting balance ifstream iFile(FILENAME.c_str()); if (iFile.is_open()) { // did the file open? if so, read the balance iFile >> balance; iFile.close(); } else { // if the file did not open or does not exist, create a // random number for the starting balance srand( time(0) ); const int MIN = 1000; const int MAX = 10000; balance = rand() % (MAX - MIN + 1) + MIN; }
cout
// let's create a pointer and set it to the balance variable location double* ptrBalance = &balance; // & means "address of"
// pause before we clear the screen cout;
int main();
void withdrawal(double* ptrBalance, float dailylimit, float amount);
_getch();
// create loop variable BEFORE the loop short choice = 0;
// start the application loop do
{ // show the menu system("cls"); //clears the console screen -- for Mac, use system ("clear"); cout
// get user input cout > choice;
// run code based on the user's choice switch (choice) { case 1: deposit(ptrBalance); // passing a poointer so only four bytes have to go across the system bus! break; case 2: withdrawal(ptrBlaance, DAILY_LIMIT); // passing four byte pointer! break; case 3: //show the balance cout
// pause cout
/// Make a deposit void deposit(double* ptrBalance) { // get deposit and validate it float deposit = 0.0f;
do { cout > deposit;
if (cin.fail()) // did they give us a character instead of a number? { cin.clear(); // clears fail safe cin.ignore(INT16_MAX, ' '); // clears keyboard buffer cout
// how do we get the double value located at the pointer? // Dereference it using an asterisk!1 *ptrBalance += deposit; //same as: *ptrBalance = *ptrBalance + deposit;
cout
///Make a withdrawal void withdrawal(double* ptrBalance, float dailylimit) { // get the withdrawal (you should validate this input) float amount = 0.0f; cout > amount;
//call the overloaded method version that takes //the balance, dailylimit, and withdrawal amount withdrawal(ptrBalance, dailylimit, amount); }
/// Make a withdrawal - this overload accepts balance, dailylimit, and withdrawal amount void withdrawal(double* ptrBalance, float dailylimit, float amount) { //take away money from the account and show the balance if (amount > dailylimit) { cout *ptrBalance) /otice the asterisk to dereferance pointer { cout
cout
while (choice != EXIT_VALUE);
ofstream oFile(FILENAME.c_str()); oFile
return 0;
void _getch() { } _________________________________________________________________________________________________________________
What am I doing wrong with my code? I have errors, so many errors. 
Week 1 Lab 25 abc E0266 as E0169 E0077 42 64 abs E0169 64 ahs E0260 70 76 100 101 ats E0169 abs E0169 abs E0169 abs E0169 abs E0169 E0169 abc E0169 104 Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab 105 108 109 abc E0169 111 "cout" is ambiguous expected a declaration this declaration has no storage class or type specifier expected a declaration explicit type is missing 'int' assumed) expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration expected a declaration explicit type is missing ('int' assumed) expected a declaration this declaration has no storage class or type specifier expected a "cout" is ambiguous "cin" is ambiguous "cout" is ambiguous "cout" is ambiguous "cout" is ambiguous "cout" is ambiguous expected a declaration abs E0169 Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp Source.cpp 112 abc E0169 114 abs E0169 115 119 120 149 Week 1 Lab 149 156 abs E0260 abs E0169 abs E0077 abs E0065 abs E0266 abc E0266 abs E0266 abc E0266 abs E0266 abs E0266 157 170 Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab Week 1 Lab 174 179 182 ab E0169 185
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
