Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I get this error message in Visual Studio when i run my program. Warning 1 warni

ID: 3557263 • Letter: I

Question

I get this error message in Visual Studio when i run my program.

Warning   1   warning C4244: 'argument' : conversion from 'double' to 'float', possible loss of data

my header for the Constructor which does this

class Savings : public Account
{
   private:
       float interestRate;

   public:
       Savings();
       Savings(Customer, double ,double);
       void makeDeposit(float);
       bool makeWithdrawal(float);
       void adjustBalance();
       virtual void view();
};
//#endif

//saving.cpp
//#include <iostream>
//#include "savings.h"
//using namespace std;

Savings::Savings()
{
   interestRate = 0.0;
}

//Account(float Bal, const Customer &pCust) : balance(Bal), cust(pCust);
Savings::Savings(Customer Cus, double b , double rate):Account(b,Cus)
{
  
   interestRate=rate;
}

the test driver is this:

const int MAX = 4;
void doTransactions (Account*);
const int NAME_SIZE = 20;
const int ID_SIZE = 6;

int main()
{
   Account* acctsPtr[MAX];
   char acctType;
   bool validType = true;
   char custName[NAME_SIZE];
   char acctID[ID_SIZE];
   double startBal;
   int aNum;

   for (aNum = 0; aNum < MAX && validType; aNum++)
   {
       cout << "Enter c for checking; s for savings; any other character to quit: ";
       cin >> acctType;
       acctType = tolower (acctType);

       if (acctType == 'c' || acctType == 's')
       {
           cout << "Enter customer name: ";
           cin >> custName;
           cout << "Enter account number: ";
           cin >> acctID;
           cout << "Enter account beginning balance: ";
           cin >> startBal;
       }

       switch (acctType)
       {
           case 'c':
               {
                   char response;
                   bool overdraftOk;

                   cout << "Does this account have overdraft protection? ";
                   cin >> response;
                   overdraftOk = (tolower(response) == 'y')? true : false;
                   Customer c (custName, acctID);
                   acctsPtr[aNum] = new Checking (c, startBal, overdraftOk);
                   doTransactions (acctsPtr[aNum]);
                   acctsPtr[aNum]->adjustBalance();

                   cout << "Balance after service charge (if any): " << acctsPtr[aNum]->getBalance() << endl;
                   break;
               }

           case 's':
               {
                   double intRate;

                   cout << "Enter current monthly interest rate: ";
                   cin >> intRate;
                   Customer c (custName, acctID);
                   acctsPtr[aNum] = new Savings (c, startBal, intRate);
                   doTransactions (acctsPtr[aNum]);
                   acctsPtr[aNum]->adjustBalance();

                   cout << "Balance after interest: " << acctsPtr[aNum]->getBalance() << endl;
                   break;
               }

           default:
               validType = false;
               aNum--;
               break;
       }
   }

   int totalAccts = aNum;
   cout << " Accounts: ";

   for (int i = 0; i < totalAccts; i++)
   {
       acctsPtr[i]->view();
       cout << " ";
   }

   for (int i = 0; i < totalAccts; i++)
       delete acctsPtr[i];

   system("pause");
   return 0;
}

void doTransactions (Account* aPtr)
{
   double depAmt, withdAmt;

   cout << "Enter total deposite: ";
   cin >> depAmt;
   aPtr->makeDeposit (depAmt);
   cout << "Balance after deposite: " << aPtr->getBalance() << endl;

   cout << "Enter total withdrawals: ";
   cin >> withdAmt;
   if (aPtr->makeWithdrawal (withdAmt))
       cout << "Balance after withdrawals: " << aPtr->getBalance() << endl;
   else
       cout << "Withdrawal not made -- balance too low " << " and no overdraft protection ";
}

Please Help!!!

Explanation / Answer

You haven't provided all code but a/c to error you are getting just change all float variables to double