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
SO I LIKE BOILED EGGS AND MY MUM WAS MAKING SALAD FOR DINNER SO I SAID DID YOU MAKE AND EGG-TRA ONE FOR ME
katovenus [111]

Answer:

now what is this

Explanation:

4 0
3 years ago
Gary has to complete a form before enrolling into an online course. A few of the fields require Gary to respond with either a "Y
zalisa [80]
I think its C. Boolean
Hope this helped!
3 0
3 years ago
Read 2 more answers
Dinah is using an IDE to write, modify, and save code. Which tool should she use?
julsineya [31]
A source code editor, hope this helps! :)
6 0
3 years ago
Read 2 more answers
What are the 3 rules of music<br><br> ps: there is no music subject so i had to put something else
Kitty [74]

Answer:

Rules that apply to all situations and accasions in the music room

Explanation:

I hope this helps

7 0
2 years ago
Read 2 more answers
Chapter 20 reading and vocab review
aev [14]

Answer:

Essentially additive editing and stringing “the good stuff” together, whereas subtractive is more about stringing all your raw footage together and “removing the bad stuff”

Additive editing feels confident and concerned with the pursuit of a specific, existing vision. And it’s faster. Subtractive editing feels like a deeper listening to what the footage is saying, and holding on to many potential permutations.

Explanation:

Addictive editing -  creating a program from raw footage by starting by starting with nothing and adding selected components

Subtraction editing  - creating a program by removing redundant or poor quality material from the original footage

7 0
2 years ago
Other questions:
  • ​You work at a call center of a large bank where you answer credit card services related questions from customers. Lately, you h
    14·1 answer
  • A hard drive cannot be partitioned until the device _________ is set.
    15·1 answer
  • Write a recursive function, replace, that accepts a parameter containing a string value and returns another string value, the sa
    5·1 answer
  • Can you combine a wireless and wired lan in the same home
    14·1 answer
  • The sample remote access policy document from the hospital that you reviewed in the lab showed that the Remote Access Domain is
    15·2 answers
  • MICR is an input or output devices
    5·1 answer
  • When a partition is formatted with a file system and assigned a drive letter it is called a volume?
    10·1 answer
  • Select the antonym for given word freedom
    7·2 answers
  • Create a program that generates a report that displays a list of students, classes they are enrolled in and the professor who te
    11·1 answer
  • A personal computer (pc) or ____ is a small computer system designed to be used by one person at a time.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!