1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nikklg [1K]
3 years ago
5

Consider the following class declaration. This is the continuation of the lab 8, exercise 1. Suppose that management now wants t

o change the customer management system so that the credit limit applies to the unpaid balance on the account. A new purchase will be disallowed when it would cause the unpaid balance to exceed the credit limit. You'll need to declare or modify data members, constructors, accessors, and mutators to expand the Customer class from LAB 8 Exercise 1 to return a value specifying that a new purchase would exceed the credit limit. This can be calculated by passing the purchase price into a member function, adding this to the unpaid balance, and comparing it to the credit line. Enhance your Customer class to fulfill the new requirements. Write a program that tests the new feature. Insert print statements into your code to provide a trace of your program’s execution of a series of sales.. Use the filename customer.h, customer.cpp and customerDemo.cpp for your programs (5 points)

Computers and Technology
1 answer:
anzhelika [568]3 years ago
8 0

Answer:

Explanation:

The code is implemented in C++ and comments to aid understanding are provided below.

Will be attaching code for these 3 files:

CustomerDemo.cpp

Customer.cpp

Customer.h

Source code for CustomerDemo.cpp:

#include <iostream>

#include "Customer.h"

using namespace std;

int main()

{

string response = "y";

double val;

Customer a("John Doe", "101 Main St.", "Rockford", "IL", "61801", 100.00);

Customer b("J", "101 Main St.", "Rockford", "IL", "61801", 100.00);

Customer c("Doe", "101 Main St.", "Rockford", "IL", "61801", 100.00);

Customer z("D", "101 Main St.", "Rockford", "IL", "61801", 100.00);

while ( response == "y" )

{

cout << "Purchase value (in $): ";

cin >> val;

if(!c.add_purchase(val)) break;;

cout << "Do you want to purchase another item (y/n)? ";

cin >> response;

}

cout << "Please pay the balance of $" << c.get_unpaid_balance() << endl;

/* cout << "would you like to pay off part of the unpaid balance?" <<endl;

if (response== "y")

{

cout< "Enter the payment amoun (in $)";

(c.get_

cout << "Do you want to purchase another item (y/n)? ";

cin >> response;

}*/

system("pause");

return 0;

}

→ Source code for Customer.cpp:

#include "Customer.h"

Customer::Customer()

{

name = "";

address = "";

city = "";

state = "";

zipcode = "";

credit_limit = 0;

year_to_date_purchases = 0;

unpaid_balance = 0;

}

Customer::Customer(string n, string a, string c, string s, string z, double cl)

{

name = n;

address = a;

city = c;

state = s;

zipcode = z;

credit_limit = cl;

year_to_date_purchases = 0;

unpaid_balance = 0;

}

void Customer::increase_limit(double amount)

{

credit_limit += amount;

}

string Customer::get_name() const

{

return name;

}

string Customer::get_address() const

{

return address;

}

string Customer::get_city() const

{

return city;

}

string Customer::get_state() const

{

return state;

}

string Customer::get_zipcode() const

{

return zipcode;

}

double Customer::get_credit_limit() const

{

return credit_limit;

}

double Customer::get_unpaid_balance() const

{

return unpaid_balance;

}

bool Customer::add_purchase(double val)

{

if ( (val + unpaid_balance) > credit_limit )

{

cout << "Not enough credit limit. Purchase cannot be completed.\n";

return false;

}

year_to_date_purchases += val;

unpaid_balance += val;

cout << "Purchase successful.\n"; //trace message

return true;

}

void Customer::pay_balance(double payment)

{

unpaid_balance -= payment;

}

→  Source code for Customer.h:

#ifndef CUSTOMER_H

#define CUSTOMER_H

#include <string>

#include <vector>

#include <iostream>

using namespace std;

class Customer

{

public:

//constructors    

Customer();

Customer(string name, string address, string city,

string state, string zipcode, double);

//accessors    

string get_name() const;

string get_address() const;

string get_city() const;

string get_state() const;

string get_zipcode() const;

double get_credit_limit() const;

double get_unpaid_balance() const;

//mutators

void increase_limit(double amount);

bool add_purchase(double val);

void pay_balance(double payment);

private:

string name;

string address;

string city;

string state;

string zipcode;

double credit_limit;

double year_to_date_purchases;

double unpaid_balance;

};

#endif

cheers i hope this helped !!

You might be interested in
Define graphics packaging​
Sav [38]

Answer:

"A graphics package is an application that can be used to create and manipulate images on a computer. There are two main types of graphics package: painting packages."

Explanation:

i looked it up like a normal person

jeez does nobody use google on here lol

4 0
3 years ago
The steps for creating a newsletter are to _____.
lys-0071 [83]
Puting your ideas together every write has to do that and also gather true information, and making a intering story for your readers.
7 0
3 years ago
Read 2 more answers
You can use a(n) ____ to visually separate related controls from other controls on the form.
maksim [4K]

Answer:

The correct answer to the following question will be Group Box.

Explanation:

Group Box:

  • A type container that contains many types of controls that are usually related to each other in the form.
  • It usually provides the identified grouping for other controls.
  • used for the subdivision of the forms.
  • Separation of the controls can be done with the help of grouping by group box.

5 0
3 years ago
PLZZZZ HELPPP and please don’t send a link , Explain how the processing stage contributes to a computer creating an output.
-Dominant- [34]
The output/interpretation stage is the stage at which data is finally usable to non-data scientists. It is translated, readable, and often in the form of graphs, videos, images, plain text, etc.).
3 0
3 years ago
What is a output devices?
V125BC [204]
Any piece of computer hardware equipment which converts information into a human-perceptible form or, historically, into a physical machine-readable form for use with other non-computerized equipment. It can be text, graphics, tactile, audio, or video.
3 0
2 years ago
Read 2 more answers
Other questions:
  • What type of installation should you perform if you want to install a 64-bit version of Windows on a computer that already has a
    8·1 answer
  • Which two statements are true regarding the user exec mode? (choose two.)?
    6·1 answer
  • What does rwd stand for?
    8·2 answers
  • What are the first and the last physical memory addressesaccessible using
    10·1 answer
  • Write the definition of a class Counter containing: An instance variable named counter of type int. An instance variable named l
    14·1 answer
  • Which of the following would most likely be responsible for configuring firewalls and IDPSs, implementing security software, and
    8·2 answers
  • A(n) ____________________ is hardware or software that blocks or allows transmission of information packets based on criteria su
    13·1 answer
  • You should always be afraid to use the internet<br><br> True or false?
    11·1 answer
  • Answer this crossword for brainliest and 15 points
    9·1 answer
  • What represents a user’s specific preferences?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!