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
AveGali [126]
3 years ago
12

Design a class called NumDays. The class’s purpose is to store a value that represents a number of work hours and convert it to

a number of days. For example, 8 hours would be converted to 1 day, 12 hours would be converted to 1.5 days, and 18 hours would be converted to 2.25 days. The class should have a constructor that accepts a number of hours, as well as member functions for storing and retrieving the hours and days. The class should also have the following overloaded operators:
+ addition operator: When two NumDays objects are added together, the overloaded + operator should return the sum of the two objects hours members.
-subtraction operator: When one NumDays object is subtracted from another, the overloaded- operator should return the difference of the two objects hours members.
++ prefix and postfix increment operators. These operators should increment the number of hours stored in that object. When incremented, the number of days should automatically be recalculated.
-- Prefix and postfix decrement operators. These operators should decrement the number of hours stored in that object. When decremented, the number of days should automatically be recalculated.
Computers and Technology
1 answer:
Afina-wow [57]3 years ago
3 0

Answer:

See explaination

Explanation:

#include <iostream>

using namespace std;

class NumDays{

int hours;

float day;

public:

NumDays()

{

hours=0;

day=0.0;

};

NumDays(int h)

{

hours=h;

day=float(h/8.0);

};

int getHour()

{

return hours;

}

float getDay()

{

return day;

}

NumDays operator +(NumDays obj)

{

int h=getHour()+obj.getHour();

NumDays temp(h);

return temp;

}

NumDays operator -(NumDays obj)

{

int h=getHour()-obj.getHour();

NumDays temp(h);

return temp;

}

const NumDays& operator++() //prefix

{

++hours;

day=float(hours/8.0);

return *this;

}

const NumDays& operator--() //prefix

{

--hours;

day=float(hours/8.0);

return *this;

}

const NumDays operator++(int) //postfix

{

NumDays temp(*this);

++hours;

day=float(hours/8.0);

return temp;

}

const NumDays operator--(int) //postfix

{

NumDays temp(*this);

--hours;

day=float(hours/8.0);

return temp;

}

};

int main()

{

NumDays obj(2),obj2(10),obj3,obj4;

obj3=obj2-obj;

cout<<"'obj3=obj2-obj'=> Day:"<<obj3.getDay()<<"##Hour:"<<obj3.getHour()<<"\n";

obj3=obj+obj2;

cout<<"'obj3=obj+obj2'=> Day:"<<obj3.getDay()<<"##Hour:"<<obj3.getHour()<<"\n";

obj4=obj3++;

cout<<"'obj4=obj3++' => Day:"<<obj4.getDay()<<"##Hour:"<<obj4.getHour()<<"\n";

obj4=++obj3;

cout<<"'obj4=++obj3' => Day:"<<obj4.getDay()<<"##Hour:"<<obj4.getHour()<<"\n";

obj4=obj3--;

cout<<"'obj4=obj3--' => Day:"<<obj4.getDay()<<"##Hour:"<<obj4.getHour()<<"\n";

obj4=--obj3;

cout<<"'obj4=--obj3' => Day:"<<obj4.getDay()<<"##Hour:"<<obj4.getHour()<<"\n";

};

You might be interested in
At the data science laboratory, the data scientists and data engineers are required to process millions of data every second to
defon

Answer:

the type of computer system that is required for processing of scientific data is : supercomputer

for distribution of data over a network :Client/server computing

working from home :A laptop

3 0
3 years ago
At the end of the day, you finish a job only to find that the user you were doing it for had to leave. What should you do
Vika [28.1K]

The way to proceed in the situation presented would be:

  • Finish the process started to help that user and continue with the other tasks of the day.

<h3>How to serve a customer properly?</h3>

In different work positions we have the possibility of personally or virtually assisting clients by carrying out procedures to help them improve their service or experience with the company.

Companies have developed complete customer service systems so that their employees know how to proceed in different specific situations in which their customers require help.

In the situation described, the most appropriate thing would be to finish the process required by the user and continue with the other tasks of the day that were planned.

Learn more about job in: brainly.com/question/2018598

7 0
2 years ago
Which of the following keys moves the insertion point to the end of data in a cell?
IgorC [24]
C) End is the key that moves the insertion point to the end of data in a cell. 
5 0
3 years ago
Please check my answer! (Java)
gtnhenbr [62]

13 is the correct answer.

7 0
3 years ago
Which tab is used to create a
Anna71 [15]

Answer:

Mail tab

Explanation:

Please mark as brainliest answer as it will also give you 3 points

7 0
3 years ago
Read 2 more answers
Other questions:
  • 14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
    13·2 answers
  • Which BI tool or technique would be most useful in predicting the likelihood of a fire in a building? a. Data mining b. Dashboar
    9·1 answer
  • Combination lock uses three numbers beween 1 and 36 with repetition , how mant combinations are possiable
    6·1 answer
  • Which biometric technique is considered nearly infallible from a scientific point of view and is increasingly preferred by crimi
    8·1 answer
  • Gloria is in her sophomore year of college and works part time. She has assignments saved on her home computer, her aunt's lapto
    6·2 answers
  • A model is replica that?
    11·2 answers
  • Ethical design refers to...
    13·1 answer
  • ) Perform error checking for the data point entries. If any of the following errors occurs, output the appropriate error message
    11·1 answer
  • When constructing policies regarding data _______________, it is important that these policies offer particular guidance on sepa
    14·1 answer
  • Identify and explain five areas where computers are used to process <br> data
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!