/*
Colesha Pearman
CIS247C
ATM Application
May 4,2020
*/
//Bring in our libaries
#include"stdafx.h"
#include<iostream>
#include<conio.h>
#include<string>
#include<fstream>//read/write to files
#include<ctime>//time(0)
#include<iomanip>//setpresision std
using namespace std;
//create constant vaules-- 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;
//prototypes
void deposit(double* ptrBalance);
void withdrawal(double* ptrBalance, float dailyLimit); //overloaded method-this verision does not take withdrawal amount
void withdrawal(double* ptrBalance, float dailyLimit, float amount); //overloaded method that takes withdrawal amount
///Enrty point to the application
int main()
{
//look for the starting balance; otherwise generate a random 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 exit,create a
//random for the starting balance
srand(time(0));
const int MIN = 1000;
const int MAX = 10000;
balance = rand() % (MAX - MIN + 1) + MIN;
}
cout << fixed << setprecision(2) << "Starting Balance:$" << balance << endl;
//pause before we clear the screen
cout << "\nPress any key to continue...";
_getch();
//let's create pointer and set it to the balance variable location
double*ptrBalance = &balance; //&means "address of"
//create loop variable BEFORE the loop
short choice = 0;
//Start the application
do
{
//show the menu
system("CIS");
cout << "Menu\n" << endl;
cout << "1)Deposit" << endl;
cout << "2)Withdrawal" << endl;
cout << "3)Check Balance" << endl;
cout << "4)Quick $40" << endl;
cout << "5)Exit" << endl;
//get user input
cout << "\nEnter your choice:";
cin >> choice;
//run code based on the user's choice
switch (choice)
{
case 1:
cout << "Making a deposit..." << endl;
break;
case 2:
cout << "Making a withdrawal..." << endl;
break;
case 3:
cout << "Showing the current balance..." << endl;
break;
case 4:
cout << "Getting a quick $40..." << endl;
break;
case 5:
cout << "\nError. Please select from the menu." << endl;
break;
}
cout << "\nPress any key to continue...";
_getch();
} while (choice != EXIT_VALUE);
// now that the application is over, write the new balance to the file
ofstream oFile(FILENAME.c_str());
oFile << balance << endl;
oFile.close();
return 0;
}
///Make a deposit
void deposit(double* ptrBalance)
{
// get deposit and validate it
float deposit = 0.0f;
do
{
cout << "\nEnter deposit amount:";
cin >> deposit;
if (cin.fail()) // did they give us a character instead of a number?
{
cin.clear(); // clears fail state
cin.ignore(INT16_MAX, '\n');
// clears keyboard buffer
cout << "\nError. Please use numbers only.\n" << endl;
deposit = -1; //set deposit to a "bad" number
continue; //restart the loop
}
if (deposit < 0.0f) //check for negative number
cout << "\nError.Invalid deposit amount.\n" << endl;
} while (deposit < 0.0f);
//how do we get the double value location at the pointer?
//Dereference it using an asterisk!
*ptrBalance += deposit; //same as:*ptrBalance = *ptrBalance + deposit;
cout << fixed << setprecision(2) << "\nCurrent ptrBalance: $" << *ptrBalance << endl; // notice the asterisk
}
/// Make a withdrawal
void withdrawal(double* ptrBalance, float dailyLimit)
{
// get the withdrawal(you should vaildate this input)
float amount = 0.0f;
cout << "\nEnter withdrawal amout:";
cin >> 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 account and show the balance
if (amount > dailyLimit)
{
cout << "\nError.Amount eceeds daily limit." << endl;
}
else if (amount > *ptrBalance) //notic the aterisk to derference the pointer!
{
cout << "\nError. Insufficient funds." << endl;
}
else
{
*ptrBalance -= amount; // same as: *ptrBalance = *ptrBalance -amount;
cout << "\nHere is your cash: $" << amount << endl;
}
cout << fixed << setprecision(2) << "\nCurrent Balance: $" << *ptrBalance << endl;
}
We need at least 9 more requests to produce the answer.
1 / 10 have requested this problem solution
The more requests, the faster the answer.
C++
Banks offer various types of accounts, such as savings,
checking, certificate of deposits, and money market, to attract
customers as well as meet their specific needs. Two of the most
commonly used accounts are savings and checking. Each of these
accounts has various options. For example, you may have a savings
account that requires no minimum balance but has a lower interest
rate. Similarly, you may have a checking account that limits the
number of checks you may write....
In c++ please How do I get my printVector function to actually print the vector out? I was able to fill the vector with the text file of names, but I can't get it to print it out. Please help #include <iostream> #include <string> #include <fstream> #include <algorithm> #include <vector> using namespace std; void openifile(string filename, ifstream &ifile){ ifile.open(filename.c_str(), ios::in); if (!ifile){ cerr<<"Error opening input file " << filename << "... Exiting Program."<<endl; exit(1); } } void...
C++ programming I need at least three test cases for the program and at least one test has to pass #include <iostream> #include <string> #include <cmath> #include <iomanip> using namespace std; void temperatureCoverter(float cel){ float f = ((cel*9.0)/5.0)+32; cout <<cel<<"C is equivalent to "<<round(f)<<"F"<<endl; } void distanceConverter(float km){ float miles = km * 0.6; cout<<km<<" km is equivalent to "<<fixed<<setprecision(2)<<miles<<" miles"<<endl; } void weightConverter(float kg){ float pounds=kg*2.2; cout<<kg<<" kg is equivalent to "<<fixed<<setprecision(1)<<pounds<<" pounds"<<endl; } int main() { string country;...
THIS IS FOR C++ PROGRAMMING USING VISUAL
STUDIO
THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING
#include "pch.h"
#include
#include
using namespace std;
// Function prototype
void displayMessage(void);
void totalFees(void);
double calculateFees(int);
double calculateFees(int bags) {
return bags * 30.0;
}
void displayMessage(void) {
cout << "This program calculates the total
amount of checked bag fees." << endl;
}
void totalFees() {
double bags = 0;
cout << "Enter the amount of checked bags you
have." << endl;
cout <<...
MAIN OBJECTIVE Develop a polymorphic banking program using the Account hierarchy created (below). C++ Capture an output. polymorphism. Write an application that creates a vector of Account pointers to two SavingsAccount and two CheckingAccountobjects. For each Account in the vector, allow the user to specify an amount of money to withdraw from the Account using member function debit and an amount of money to deposit into the Account using member function credit. As you process each Account, determine its...
C++ Design a class bankAccount that defines a bank account as an ADT and implements the basic properties of a bank account. The program will be an interactive, menu-driven program. a. Each object of the class bankAccount will hold the following information about an account: account holder’s name account number balance interest rate The data members MUST be private. Create an array of the bankAccount class that can hold up to 20 class objects. b. Include the member functions to...
im not sure why my code isnt working? include <iostream> #include <iomanip> using namespace std; int main() { int amountOfCoffee; double Price; char salesTaxChargeability; double TotalAmount; const double SALESTAX = 0.035; // 3.5 % cout << "\nEnter the number of pounds of coffee ordered in Pounds :"; cin >> amountOfCoffee; cout << "\nEnter the price of coffee per Pound :"; cin >> Price; cout << "\nIs sales tax Chargeable (y or n): "; cin >> salesTaxChargeability; if ( (salesTaxChargeability ==...
Trying to figure out how to complete my fourth case 4 (option exit), write a function that display a “Good Bye” message and exits/log out from user’s account displaying a menu (sign in, balance, withdraw and exit.. #include<iostream> #include <limits> using namespace std; void printstar(char ch , int n); double balance1; int main() { system("color A0"); cout<<"\n\t\t ========================================="<< endl; cout<<"\t\t || VASQUEZ ATM SERVICES ||"<< endl; cout<<"\t\t ========================================\n\n"<< endl; int password; int pincode ; cout<<" USERS \n"; cout<<" [1] -...
The following code is for Chapter 13 Programming Exercise 21. I'm not sure what all is wrong with the code written. I get errors about stockSym being private and some others after that.This was written in the Dev C++ software. Can someone help me figure out what is wrong with the code with notes of what was wrong to correct it? #include <cstdlib> #include <iostream> #include <iomanip> #include <fstream> #include <cassert> #include <string> using namespace std; template <class stockType> class...
I need help modifying this code please ASAP using C++
Here is what I missed on this code below
Here are the instructions
Here is the code
Produce correct70 pts O pts Full Marks No Marks results and statisfy requirements view longer Comments 1. Your display amount is not readable 2. I withdraw more than my balance, but I didn't see any error message description Documentations10 pts 0 pts Full Marks No Marks : comment i code and block comment...