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

This program is for C++ programming. There are two parts to this question and bo

ID: 3555783 • Letter: T

Question

This program is for C++ programming.

There are two parts to this question and both most be answered to recieve the points.

Part 1

Define a class named Customer that holds private fields for a customer ID number, last name, first name and credit limit. Include four public functions that each set one of the four fields. Do not allow any credit limit over $10,000. Include a public function that displays a Customer's data. Write a main() function in which you declare a Customer, set the Customer's fields, and display the results. Save as MyCustomer.cpp

Part 2

Write a main () function that declares an array of five Customer objects. Prompt the user for values for each Customer, and display all five Customer objects. Save as MyCustomer2.cpp

I think my rating speaks for itself. Points will be awarded as soon as the two answers are submitted. And as always thanks for any and all help!

Explanation / Answer

part 1..

class file

#include<iostream>
#include<cstring>
using namespace std;

class customer
{
private:
int cus_id;
char last[100];
char first[100];
int credit;
public:
void set_cus_id(int n)
{
cus_id =n;
}
void set_last(char a[])
{
strcpy(last,a);
}
void set_first(char b[])
{
strcpy(first,b);
}
void set_credit(int c)
{
credit = c;
}
void disp()
{
cout<<"Customer id : "<<cus_id<<endl;
cout<<"First name : "<<first<<endl;
cout<<"Last name : "<<last<<endl;
cout<<"Credit : "<<credit<<endl;
}
};

mycustomer.cpp file

#include<iostream>
#include<cstring>
#include "customer.cpp"

using namespace std;

int main()
{
customer c;
c.set_cus_id(1234);
c.set_last("Kumar");
c.set_first("Sumit");
c.set_credit(10000);
c.disp();
system("pause");
return 0;
}

mycustomer2.cpp file

#include<iostream>
#include "customer.cpp"
using namespace std;
int main()
{
customer c[5];
int credit,id;
char first[100];
char last[100];
for(int i=0;i<5;i++)
{
cout<<"Enter customer_id : "<<endl;
cin>>id;
c[i].set_cus_id(id);
cout<<"Enter First name : "<<endl;
cin>>first;
c[i].set_first(first);
cout<<"Enter Second name : "<<endl;
cin>>last;
c[i].set_last(last);
cout<<"Enter credit : "<<endl;
cin>>credit;
c[i].set_credit(credit);
}
  
for (int i=0;i<5; i++)
{
cout<<endl<<endl;
c[i].disp();
}
system("pause");
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote