In: Computer Science
Copy the content of the source code into Visual Studio. Fill in the __BLANKS__ with proper code and make it work! (HINT: you will be creating two files with this source code; one .cpp file and one .h file].
Please alter the code so that:
CODE:
#include<iostream>
#include<cstring>
#include"customer.h"
using namespace std;
//The header file of the class CUSTOMER used is included
void main()
{
___BLANK___Credit;
printf("Customer Name Payment Due \n");
printf("\n");
Credit=100.0;
for (int i=1; i<=3; i++) {
CUSTOMER Customer;
___BLANK___.ConstCustomer(i);
printf ("%s", Customer.ReturnCustomerName());
printf("%4.2f \n", Customer.CustomerDue(Credit));
___BLANK___
}
//**** Class CUSTOMER definition ****
//File is "customer.h"
class CUSTOMER
//Class declaration
{
private:
//Attributes
int CustomerNumber;
___BLANK___ CustomerName[20];
___BLANK___ CustomerBalance;
char CustomerPhone[15];
public:
CUSTOMER ()
{
//Constructor is actually implemented by the method
//void ConstCustomer(int)
};
//Operations
//The following procedure simulates the system to read a
//database/data file which records information of customer
void ConstCustomer(int CN) {
CustomerNumber=CN;
if (CustomerNumber==1)
{ strcpy_s(CustomerName, "John ");
CustomerBalance=-200.05;
strcpy_s(CustomerPhone, "123 1234");
}
if (CustomerNumber==2)
{ strcpy_s(CustomerName, "Anne ");
CustomerBalance=-200;
strcpy_s(CustomerPhone, "123 2345");
}
if (CustomerNumber==3)
{ strcpy_s(CustomerName, "Greg ");
CustomerBalance=100.78;
strcpy_s(CustomerPhone, "123 7890");
}
}
//Next are methods of the CUSTOMER class ...
___BLANK___ ___BLANK___
{return CustomerName;};
___BLANK___ *ReturnCustomerPhone()
{return CustomerPhone;};
double ReturnCustomerBalance()
{return CustomerBalance;};
double CustomerDue(double CR) {
___BLANK___ ___BLANK___ ___BLANK___
if ((CustomerBalance+CR)<0)
{ DueAmount=(CustomerBalance+CR)*-1; }
else
{ DueAmount=0; };
___BLANK___ (DueAmount);
}
___BLANK___
no changes take in given code only blanks are filled with appropriate content:





Raw_code:
customer.h:
class CUSTOMER
//Class declaration
{
private:
//Attributes
int CustomerNumber;
char CustomerName[20];
double CustomerBalance;
char CustomerPhone[15];
public:
CUSTOMER ()
{
//Constructor is actually implemented by the method
//void ConstCustomer(int)
};
//Operations
//The following procedure simulates the system to read a
//database/data file which records information of customer
void ConstCustomer(int CN) {
CustomerNumber=CN;
if (CustomerNumber==1)
{ strcpy_s(CustomerName, "John ");
CustomerBalance=-200.05;
strcpy_s(CustomerPhone, "123 1234");
}
if (CustomerNumber==2)
{ strcpy_s(CustomerName, "Anne ");
CustomerBalance=-200;
strcpy_s(CustomerPhone, "123 2345");
}
if (CustomerNumber==3)
{ strcpy_s(CustomerName, "Greg ");
CustomerBalance=100.78;
strcpy_s(CustomerPhone, "123 7890");
}
}
//Next are methods of the CUSTOMER class ...
char* ReturnCustomerName()
{return CustomerName;};
char *ReturnCustomerPhone()
{return CustomerPhone;};
double ReturnCustomerBalance()
{return CustomerBalance;};
double CustomerDue(double CR) {
double DueAmount ;
if ((CustomerBalance+CR)<0)
{ DueAmount=(CustomerBalance+CR)*-1; }
else
{ DueAmount=0; };
return (DueAmount);
}
};
customer.cpp:
#include<iostream>
#include<cstring>
#include"customer.h"
using namespace std;
//The header file of the class CUSTOMER used is included
int main()
{
double Credit;
printf("Customer Name Payment Due \n");
printf("\n");
Credit=100.0;
for (int i=1; i<=3; i++) {
CUSTOMER Customer;
Customer.ConstCustomer(i);
printf ("%s", Customer.ReturnCustomerName());
printf("%4.2f \n", Customer.CustomerDue(Credit));
}
}
code after adding my details and my instructors details:
only Raw_code and output:
customer.h:
class CUSTOMER
//Class declaration
{
private:
//Attributes
int CustomerNumber;
char CustomerName[20];
double CustomerBalance;
char CustomerPhone[15];
public:
CUSTOMER ()
{
//Constructor is actually implemented by the method
//void ConstCustomer(int)
};
//Operations
//The following procedure simulates the system to read a
//database/data file which records information of customer
void ConstCustomer(int CN) {
CustomerNumber=CN;
if (CustomerNumber==1)
{ strcpy_s(CustomerName, "John ");
CustomerBalance=-200.05;
strcpy_s(CustomerPhone, "123 1234");
}
if (CustomerNumber==2)
{ strcpy_s(CustomerName, "Anne ");
CustomerBalance=-200;
strcpy_s(CustomerPhone, "123 2345");
}
if (CustomerNumber==3)
{ strcpy_s(CustomerName, "Greg ");
CustomerBalance=100.78;
strcpy_s(CustomerPhone, "123 7890");
}
if (CustomerNumber == 4){
strcpy_s(CustomerName, "Krishna ");
CustomerBalance=-800.68;
strcpy_s(CustomerPhone, "369 7890");
}
if (CustomerNumber == 5){
strcpy_s(CustomerName, "Sai ");
CustomerBalance=-700.98;
strcpy_s(CustomerPhone, "369 9890");
}
}
//Next are methods of the CUSTOMER class ...
char* ReturnCustomerName()
{return CustomerName;};
char *ReturnCustomerPhone()
{return CustomerPhone;};
double ReturnCustomerBalance()
{return CustomerBalance;};
double CustomerDue(double CR) {
double DueAmount ;
if ((CustomerBalance+CR)<0)
{ DueAmount=(CustomerBalance+CR)*-1; }
else
{ DueAmount=0; };
return (DueAmount);
}
};
customer.cpp:
#include<iostream>
#include<cstring>
#include"customer.h"
using namespace std;
//The header file of the class CUSTOMER used is included
int main()
{
double Credit;
printf("Customer Name Payment Due \n");
printf("\n");
Credit=100.0;
for (int i=1; i<=5; i++) {
CUSTOMER Customer;
Customer.ConstCustomer(i);
printf ("%s", Customer.ReturnCustomerName());
printf("%4.2f \n", Customer.CustomerDue(Credit));
}
}
output:
