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
Tcecarenko [31]
2 years ago
6

Define a class named Money that stores a monetary amount. The class should have two private integer variables, one to store the

number of dollars and another to store the number of cents. Add accessor and mutator functions to read and set both member variables. Add another function that returns the monetary amount as a double. Write a program that tests all of your functions with at least two different Money objects.
Computers and Technology
1 answer:
WINSTONCH [101]2 years ago
6 0

Answer:

#include<iostream>

using namespace std;

class Money{

    private:

        int dollars;  

       int cents;

   public:

       Money(int d=0, int c=0){

          setDollar(d);

          setCent(c);

       }

       void setDollar(int d){

           dollars = d;

       }

       void setCent(int c){

           cents = c

       }

       int getDollar() {

           return dollars;

       }

       int getCent() {

           return cents;

       }

       double getMoney(){

          return (dollars + (cents/100));

       }

};

// testing the program.

int main(){

  Money Acc1(3,50);

  cout << M.getMoney() << endl;

  Money Acc2;

  Acc2.setDollars(20);

  Acc2.setCents(30);

  cout <<"$" << Acc2.getDollars() << "." << Acc2.getCents() << endl;

  return 0;

}

Explanation:

The C++ source code defines the Money class and its methods, the class is used in the main function as a test to create the instances of the money class Acc1 and Acc2.

The object Acc2 is mutated and displayed with the "setDollar and setCent" and "getDollar and getCent" methods respectively.

You might be interested in
CPT (Current Procedural Terminology) codes consist of 3-4 numbers representing a unique service. True False
xz_007 [3.2K]
This is in fact false to my knowledge
4 0
3 years ago
R15. Suppose there are three routers between a source host and a destination host. Ignoring fragmentation, an IP datagram sent f
maria [59]

Answer:

The answers are: an IP datagram, and 3 forwading tables.

Explanation:

An IP datagram sent from a source host to a destination host will travel through 8 interfaces. 3 forwarding tables will be indexed to move the datagram from source to destination.

8 0
2 years ago
Help!!!!!!<br>please<br>Who will give the answer I'll mark him/her as brainlist..​
damaskus [11]
17, 12.5, 6, and 10. HOPE THIS HELPS
4 0
2 years ago
At what two layers of the osi model are lan and wan protocols likely to differ??
Anuta_ua [19.1K]
A LAN is connecting two or more computers to form a cable network between them.
<span>A WAN is connecting two or more computers over a broad area to form a cable network between them.</span>
5 0
3 years ago
Advantages of machine language​
morpeh [17]

Machine Language is a language used to communicate with the Central Processing Unit (also known as the CPU)

6 0
3 years ago
Other questions:
  • For a wire with a circular cross section and a diameter = 3.00mm calculate the following: (m means meter. mm means millimeter. c
    5·1 answer
  • ⇒PLEASE HELP ME!!!!!!!!∧_∧
    15·2 answers
  • What should be used to keep a tablet dry?
    13·1 answer
  • Gta! ! ! !!aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    11·2 answers
  • in python, using the simplest form the print_seconds function so that it prints the total amount of seconds given the hours, min
    10·1 answer
  • Which method is the quickest for removing multiple different indent types applied to a paragraph
    11·2 answers
  • What is a killer app??
    10·1 answer
  • If I got a monitor and kept my garbage laptop could I play games on max graphics?
    13·1 answer
  • ¿ El Parque Fray y Jorge es un patrimonio Cultural/Natural o patrimonial de Chile ?
    14·1 answer
  • Data in the form of digits is called
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!