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]
2 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]2 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
An Excel file that contains one or more worksheets
lutik1710 [3]

Answer:

three sheets

Explanation:

A workbook is an Excel file that contains one or more worksheets. Each of the workbook 039;s worksheets are in separate tabs on the bottom of the Excel window. By default, a new Excel workbook will contain three worksheets.

7 0
2 years ago
Will give brainliest
Alex73 [517]

Answer:

B

Explanation:

Im a 100% sure.

5 0
2 years ago
When solving a problem in a group situation, which of the following traits should be demonstrated?
kakasveta [241]

Answer:

compromise should be demonstrated

8 0
2 years ago
Write a program. Commence the change to be dispensed from a vending machine. An item machine can cost between $0.25 send a dolla
SSSSS [86.1K]

Answer:

Explanation:

The objective of this question is to write a java program for a vending machine.

/* This program finds out what amount the vending machine is going to dispense. A given item in the machine can cost between $0.25 and a dollar in five-cent increments (25, 30, 35, 40...90, 95 or 100), and the machine accepts only a dollar bill to pay for the item. */

// Compile: javac PP10. java

// Run: java PP10

// imported the scanner class from util package.

import java. util. Scanner;

//class declaration

public class PP10 {

// main method is defined here.

       public static void main(String[]   args)

          {

// declaration of the variables.

             Scanner keyboard=new Scanner (System.in):

//taking the string type input

              int nl, amount, n2, n3, n4, n5;

            System.out.println("Enter price of item (from 20

cents to a dollar, in 5-cents) :");

             n1=keyboard. nextInt ();

            System.out.println("You bought an item for "+n1+"

cents and gave me a dollar");

            System.out.println ("so your change is ");

//the amount is first calculated.

          amount=100-n1;

// quarter value is calculated

            n2=amount/25;

// rest amount is get here.

            amount=amount%25;

// dime value is calculated

             n3-amount/10;

// rest amount is calculated

            amount=amount%10;

// value of nickel is calculated here

            n4=amount/5;

// rest amount is calculated

            amount=amount%5;

//at last the number of pennies is get

            n5=amount;

// Display output

              System. out . println(n2+" quarters") :

              System. out . println(n3+" dimes") ;

              System. out . println(n4+" nickels") ;

              System. out . println(n5+" pennies") ;

       }

  }

Output:

Enter the price of the item (from 20 cents to a dollar, in 5 - cents):

So, you bought an item for $0.45 and gave me one dollar; thus, your change is

2 quarters

0 dimes

1 nickel

0 pennies

4 0
3 years ago
Write a program that generates 100 random numbers and keeps a count of how many of those random numbers are even and how many of
Anvisha [2.4K]

Answer:

import random

numbers = []

even = 0

odd = 0

for i in range(100):

   numbers.append(random.randint(1, 200))

for i in range(100):

   if numbers[i] % 2 == 0:

       even += 1

   else:

       odd += 1

print("Even:", even)

print("Odd:", odd)

Explanation:

Gg ez.

8 0
2 years ago
Other questions:
  • Vaporization is the process in which liquid is sufficiently cooled to change states of matter from a liquid to a vapor true or f
    8·1 answer
  • Given the commands below, what do they do? for (position = 1 through aList.getLength()/2) { a = aList.getEntry(aList.getLength()
    11·1 answer
  • A senior center would like to add a new computer to their library so that members can check their email and read book reviews
    11·2 answers
  • What are features of a product?
    8·2 answers
  • Count input length without spaces, periods, or commas Given a line of text as input, output the number of characters excluding s
    8·2 answers
  • How is counting in this circle and square system similar to how we count in our regular lives? How is it different?
    15·1 answer
  • Which location-sharing service offers items for users as a gaming component and also allows them to collectively link their chec
    9·2 answers
  • You have just purchased a motherboard that has an LGA 1156 socket for an Intel Pentium processor. What type of memory modules wi
    14·1 answer
  • What is one pass of a coding sequence called?​
    13·2 answers
  • Writing queries in sql to compile data from a database is related to the physical level of databases true or false?.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!