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
16. Budget Analysis Write a program that asks the user to enter the amount that he or she has budgeted for a month. A loop shoul
strojnjashka [21]

Answer:

import java.util.Scanner;

public class num8 {

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter month's budget");

       double monthBudget = in.nextDouble();

       double totalExpenses = 0.0;

       double n;

       do{

           System.out.println("Enter expenses Enter zero to stop");

           n = in.nextDouble();

           totalExpenses += n;

       }while(n>0);

       System.out.println("Total expenses is "+totalExpenses);

System.out.println("The amount over your budget is "+ Math.abs(monthBudget-totalExpenses));

   }

}

Explanation:

  • Using Java programming language
  • Prompt user for month's budget
  • Use Scanner class to receive and store the amount entered in a variable
  • Use a do while loop to continuously request user to enter amount of expenses
  • Use a variable totalExpenses to add up all the expenses inside the do while loop
  • Terminate the loop when user enters 0 as amount.
  • Subtract totalExpenses from monthBudget and display the difference as the amount over the budget

6 0
2 years ago
A unit of measurement that describe the rate that electricity flows through a wire is an
Savatey [412]
AMPERE - a unit of measure for the flow of the current in a circut
8 0
3 years ago
What is analog computer? where is it used​
hichkok12 [17]

Explanation:

analogue computer is in computer which is used to process analogue data.

Analogue computer were widely used in scientific and industrial application

3 0
2 years ago
Read 2 more answers
Can someone please tell me what I’m doing wrong ? Please and it’s due on Thursday!!
liberstina [14]

Answer:

Sure. In Unit test 5, it's looking for 1 instead of 0. You are returning 0 instead of 1.

0 requires 1 digit to express it and should therefore return 1.

In line 6, change the 0 to a 1.

8 0
2 years ago
Lin is creating a template for the configuration of Windows servers in her organization. The configuration includes the basic se
larisa86 [58]

The type of document should she create is  baseline document. Check more about the term Baseline below.

<h3>What is a Baseline document?</h3>

A Baseline document is known to be a kind official or legalized document that has passed through some measures of start approval and was used for its purpose.

Note that for Lin to be able to make the template for the configuration of Windows servers, the type of document that she can create is  baseline document.

Learn more about Windows servers  from

brainly.com/question/14526761

#SJ1

3 0
1 year ago
Other questions:
  • What kind of problems could you run into if you format a cell with the wrong format for the data type?
    15·2 answers
  • Which unit of measurement related to quantity
    12·2 answers
  • Which software is primarily used to create
    15·2 answers
  • How does the post process alert the user if it detects a hardware problem during the post process?
    6·1 answer
  • Pls help will give brainlest​
    15·2 answers
  • What is the best stratiget to avoid paying intrest in your credit cared
    13·1 answer
  • There are two circular grounds Ground-A and Ground-B. Ground-A is having diameter of 15 meters and Ground-B is having diameter o
    7·1 answer
  • Which step in the software development life cycle involves making improvements based on user feedback?
    15·1 answer
  • Name any three areas of of application of excel.
    12·1 answer
  • How ict tools changed the way we live explain it​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!