Question

In: Computer Science

Copy the content of the source code into Visual Studio. Fill in the __BLANKS__ with proper...

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:

  • YOUR first and last name appears as the fourth customer [Make up your balance and phone number.]
  • Your Instructors first and last name appears as the fifth customer [Make up the balance and phone number.]
  • There is a $ symbol in front of all dollar amounts
  • The dollar amounts are aligned (right to left so that the cents symbol "." lines up)

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___

Solutions

Expert Solution

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:


Related Solutions

Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program // This program uses a function that returns a value. #include <iostream> using namespace std; // Function prototype int sum(int num1, int num2); int main() {    int value1 = 20,   // The first value        value2 = 40,   // The second value        total;         //...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any...
Download the attached file/s, copy and paste the code segment/s into your visual studio or any other C++ IDE and run it. You will have to implement a small intentional bug in your program and post it for other students to debug. To be able to receive your full discussion points, you need to submit the following. Following is your check list and rubric       Attach your .cpp file/s with an implemented bug - 20pnts       Describe what the code...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least...
VISUAL STUDIO CODE Use a for loop for to create "password". Request the password at least 3 times. If the password is 12345, the procedure ends, if the correct password entered, close excel saving changes. THANKS
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
I need the code for following in C++ working for Visual studio please. Thanks Use a...
I need the code for following in C++ working for Visual studio please. Thanks Use a Struct to create a structure for a Player. The Player will have the following data that it needs maintain: Struct Player int health int level string playerName double gameComplete bool isGodMode Create the 2 functions that will do the following: 1) initialize(string aPlayerName) which takes in a playername string and creates a Player struct health= 100 level= 1 playerName = aPlayerName gameComplete = 0...
Windows Interprocess communication. WM_CopyData IPC (data copy) - source code (c++) windows data copy IPC code
Windows Interprocess communication. WM_CopyData IPC (data copy) - source code (c++) windows data copy IPC code
using Visual Studio write a code containing a main() program that implements the coin change state...
using Visual Studio write a code containing a main() program that implements the coin change state machine in C++ according to the guidance given in Translating a state machine to C++ Test your code using prices 1 and 91 cents, and assume change is calculated from a dollar bill. Copy and paste your console output to a text editor and save the result in a single file named console.txt. Upload your exercise081.cpp and console.txt files to Canvas.
Please code in C#-Visual Studio Tasks The program needs to contain the following A comment header...
Please code in C#-Visual Studio Tasks The program needs to contain the following A comment header containing your name and a brief description of the program Output prompting the user for the following inputs: Name as a string Length of a rectangle as a double Width of a rectangle as a double Length of a square as an int After accepting user input, the program outputs the following: User name Area of a rectangle with dimensions matching the inputs Area...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file...
use VISUAL STUDIO CODE to write this javascript program Exercise 1 (a) Create a HTML file that uses createElement and appendChild to dynamically insert three paragraphs when a button is clicked. (b) Create a HTML file that includes JavaScript that is similar to: let recs = [“my item …1”,”my item…2”, …] i.e. an array that contains several CSV item records. When the user clicks a button, each array element will be rendered as a list element. Use a HTML list....
fix the code with constant expression error exrpession below in visual studio #include <iostream> #include <cstdlib>...
fix the code with constant expression error exrpession below in visual studio #include <iostream> #include <cstdlib> #include <ctime> void insertion_sort(int array[], int size, int start); void heap_sort(int B[], int n); void build_max_heap(int B[], int n); void max_heapify(int B[], int i, int n); void quick_sort(int B[], int p, int r); int partition(int B[], int p, int r); int main() {    int m = 10, Nf = 20000, Ns = 1000, delta = 1000, A[m][Nf];    for (int i = 0;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT