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
Using C++
sweet-ann [11.9K]

Answer:

#include<iostream>

using namespace std;

void OutputMinutesAsHours(double origMinutes) { //Same as question

   double hours=origMinutes/60; //solution is here

   cout<<hours;

}

//Below is same as mentioned in question

int main() {

OutputMinutesAsHours(210.0);

cout << endl;

return 0;

}

OUTPUT :

3.5

Explanation:

In the above code, only two lines are added. To convert minutes into hours we have to divide them 60, so we take minutes as input and define a new variable of double type which stores minutes converted to hours and then that variable is printed to console. For 210, it gives 3.5, similarly for 3600 it gives 60 and so on.

6 0
3 years ago
These tools give presenters more freedom to move about the room and interact with their audience.
12345 [234]

Answer:I would say laser pointer and remote

Explanation:

The LCD projector normally isnt moved around during a presentation and the laptop computer is usually also stationary

4 0
2 years ago
Read 2 more answers
One of the difficult decisions a systems analyst has to make when it comes to software is whether to recommend making, buying, o
Mademuasel [1]

Answer:

Explanation:

There are different advantages to buy commercial software like:

- Is a system used for other companies, we will have good referents with the feedback of them.

- Support, we should have support twenty-four hours, if a system doesn't have good support, we must not buy the software.

- We can choose software with a lower initial cost, this depends on our needs.

3 0
2 years ago
An access control system that grants users only those rights necessary for them to perform their work is operating on which secu
solmaris [256]

Answer:

B. Least privilege                

Explanation:

  • The principle of least privilege an important principle in computer security.
  • It limits the access rights for users and only grant them with the rights that are sufficient for them to perform their required task.
  • For example a user is granted privilege to execute a file or manipulate data or use only the resources that are required for them to perform a particular task.
  • This principle can be used only to limit and control access rights to system resources and applications.
  • The least privilege is beneficial as it reduces the risk of unauthorized access.
  • For example a user whose task is data entry and has nothing to do with controlling access or granting access rights to users, will only be allowed to enter data to the DB by the principle of least privilege.
7 0
3 years ago
Write a program that asks the user for the number of males and the number of females registered in a class. The program should d
Bond [772]

Answer:

import java.util.Scanner;

public class PercentagePopulation {

public static void main(String[] args) {

 // 1. Create an object of the Scanner class

 // This will allow for user's inputs

 Scanner input = new Scanner(System.in);

 // 2. Create a prompt asking the user to enter the number of males

 System.out.println("Please enter the number of males");

 // 3. Receive the number entered by the user and store in an int

 // variable called  number_of_males.

 int number_of_males = input.nextInt();

 // 4. Create a prompt asking the user to enter the number of

               // females

 System.out.println("Please enter the number of females");

 // 5. Receive the number entered by the user and store in an int

 // variable  called, number_of_females

 int number_of_females = input.nextInt();

 // 6. Find the sum of the number of males and females

 // Store the result in an int variable called total.

 int total = number_of_males + number_of_females;

 // 7. Find the percentage of males by using the appropriate

 // formula.  Do a type-casting to allow for division in floating point

               // representation by prepending the number_of_males by (double)

 double percentagemales = (double) number_of_males / total * 100.0;

 // 8. Find the percentage of females by using the appropriate

 // formula.  Do a type casting to allow for division in floating point

               // representation by prepending the number_of_males by (double)

 double percentagefemales = (double) number_of_females / total * 100.0;

 // 9. Print out the results

 System.out.println("Percentage males : " + percentagemales + "%");

 System.out.println("Percentage females : " + percentagefemales + "%");

}

}

Explanation:

Please go through the comments in the code to give an explanation of the program. The source code file has also been added to this response. Please download it and go through it.

Download java
4 0
3 years ago
Other questions:
  • What is a data mining??
    5·1 answer
  • Windows explorer has a pane located on the left side which can display the directory structure of one or more drives. what is th
    15·1 answer
  • The code segment below uses the procedure IsPartOf (list, item), which returns true if item appears in list and returns false ot
    13·1 answer
  • Which technology can be used to protect the privacy rights of individuals and simultaneously allow organizations to analyze data
    13·1 answer
  • A common technique for masking contents of messages or other information traffic so that opponents can not extract the informati
    14·1 answer
  • The company currently runs 60 autonomous APs and has plans to increase wireless density by 50% in the near future
    13·1 answer
  • Suppose the fixed width of an aside element in a fixed layout is 300 pixels, and the fixed width of its parent element (body) is
    15·1 answer
  • What is virtualization?
    11·2 answers
  • Technology has had
    10·1 answer
  • The courts can adjust the penalties in lawsuits to reflect the fact that infringements may be _____.
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!