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 do web servers host?<br> Websites<br> Networks<br> Firewalls<br> Zones
bixtya [17]

Answer:

Websites

Explanation:

A web server host websites, individuals or corporate websites, this helps us to show our websites in the World Wide Web, there are several companies offers this service, even we can get a free host, but a corporate website or a social media needs a lot of host recourses, these hosts are expensive than other, we could pay a web host monthly or per year.

6 0
3 years ago
The border that defines the outer boundary of a shape or other object
Over [174]
The answer is outline
8 0
3 years ago
Henry must choose which type of smart speaker to use in his home. He asked you to help him decide which one will best suit his n
ch4aika [34]

Answer:

(B) Home

Explanation:

Echo is an Amazon product.

Home is a smart speaker developed by Google.  

Cortana is a product of Microsoft.

HomePod is developed by Apple.

If Henry wants to be connected to his Google account, you would recommend him to buy Home, because it is a Google product.

4 0
3 years ago
Code the function definition for aNonclassFunction, picking up co. aNonclassFunction has no return value.
enot [183]

Answer:

b)void aNonclassFunction (Banana co);

Explanation:

In the function definition you have to pass the tell the function which type of argument it is taking.In our case we are taking a variable co of Banana type passing it to the function named aNonclassFunction having no return type.

So the definition will be like this.

void aNonclassFunction (Banana co);

6 0
3 years ago
What are the side effects of overclocking?
Oksana_A [137]

Answer:

Reduced processor lifespan, reduced fan cooler performance over time, bugs.

Explanation:

The reason is that when you overclock your processor you are increasing its base speeds in GHZ. The processor was designed to work at a determined speed, let's say 3.00 ghz. If you increase this speed to 4.00 ghz, it's not just that now it's working faster, it also draws more power from your power supply, and increases the heat that the chip is taking. Processors are designed to endure high temperatures, therefore, you will likely not see any damaged in short term, but your components life span will be severely reduced, also depending on how much you overclock the processor, and the stability of your system, you can see bugs, unexpected restarts, and strange behavior of the computer. As an example, the i5 4670k runs at 3.80 stock speed, it can reach 50 / 65 degrees under full load. If you raise the speed up to 4.5ghz it will reach 70/80 degrees, depending on your ambient temperature and other factors.

6 0
3 years ago
Other questions:
  • What is the most effect way to include space after each paragraph
    14·1 answer
  • List two reasons why “buying a computer is no easy task” ?
    12·2 answers
  • Write a statement that declares a prototype for a function powerTo, which has two parameters. The first is a double and the seco
    14·1 answer
  • Which of the following TCP/IP settings should be configured to specify DNS suffixes to use other than resolving names through a
    9·1 answer
  • Create a function (prob3_6) that will do the following: Input a positive scalar integer x. If x is odd, multiply it by 3 and add
    15·1 answer
  • This is not a feature provided by most GUIS.<br> icons<br> windows<br> forms<br> menus
    14·2 answers
  • Eugene wants to indent a paragraph, but the ruler is not present. Which tabs could Eugene use in order to accomplish his goal?
    14·1 answer
  • Ano ang ibig sabihin ng tanka<br>​
    5·1 answer
  • Can somebody tell me the Minecraft command to clear an entire world and destroy every block if u Dunno please don’t answer &gt;-
    13·1 answer
  • What are stored procedures? What kind of attack do stored procedures protect from? Identify two reasons why stored procedures ar
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!