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
Which of the following terms means the computer operating system automatically detects and installs the proper driver for a new
lukranit [14]
Plug and play installation
4 0
2 years ago
1) List at least five smaller behaviors you could break the complex behavior "brushing my teeth" into.
zhuklara [117]
Q1:
1. Go into the bathroom
2. Put toothpaste on the toothbrush
3. Place head of toothbrush on your teeth
4. Revolve in small circles
5. Repeat 4 for all of your teeth
6. Use water to wash away the toothpaste in you mouth
5 0
3 years ago
Read 2 more answers
A student is helping a friend with a home computer that can no longer access the Internet. Upon investigation, the student disco
Firlakuza [10]

Answer:

Option (D) is the right answer.

Explanation:

DHCP term used as a short form of dynamic host configuration protocol, which is used to assigns the IP address automatically according to the network.

According to the scenario, the system is getting the wrong IP address that resulting in internet disconnection which is a failure of the DHCP server because it is responsible for assigning the right IP address to the system.

Hence option (D) is the most appropriate answer.

While other options are wrong because of the following reasons:

  • Static IP is the type of IP address which is fix and doesn't change in the system after rebooting, hence it has no connection in the change of IP address.
  • If the DHCP server is working well there is no chance of interference from the surrounding device.
  • Network setting has no connection with computer power supply as SMPS is used to give power and boot system only.
8 0
3 years ago
Is ryan patrick cullen gay
pshichka [43]

who is that? ..........

6 0
3 years ago
Read 2 more answers
What is HDLC flow control?​
Likurg_2 [28]
HDLC is a synchronous Data Link layer bit-oriented protocol developed by the International Organization for Standardization (ISO).
6 0
3 years ago
Other questions:
  • WHAT SHOULD YOU DO IF AN ONCOMING CAR AT NIGHT APPROACHES WITH ITS HIGH-BEAMS ON?
    6·1 answer
  • What is life all about?
    15·2 answers
  • What registry file contains installed programs' settings and associated usernames and passwords?​?
    13·1 answer
  • Algorithm for arithmetic mean program
    13·1 answer
  • 4+4 act quick for brainliest
    10·2 answers
  • Which statement is false? Select one: a. Function printf does not care how large the array it is printing is. b. Function scanf
    9·1 answer
  • How do I modify objects in power point 2016 for an assignment
    11·1 answer
  • Which is a benefit of peer-to-peer networking?
    12·1 answer
  • Debugging 2.17.3: Debug: The Two Towers Code Hs
    15·1 answer
  • What is my mistake on this code? (Python)
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!