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
zhannawk [14.2K]
3 years ago
7

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:
stepladder [879]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
Edward is a composer and needs to listen to the most accurate music files to create his compositions. What audio file type shoul
svetoff [14.1K]

Answer:

MP3

Explanation:

From the question we are informed about Edward who is a composer and needs to listen to the most accurate music files to create his compositions. In this case, the audio file type he should use to record his music is MP3 format. MP3 format Is an audio format which is a coding use in digital audio with high quality that can be used to store songs on the computer without taking much space, but with good quality. MP3 offer to listen to his/her music clearly.

4 0
3 years ago
You have been on the phone with a user in a remote office for 30 minutes troubleshooting their minor desktop problem. No matter
Alecsey [184]

Answer:

D

Explanation:

First when you are troubleshooting a client your main goal is to solve their issue, you dont want to say hey call later i cant help you or say call someone else because picture this you need help and someone hangs up on you or says (B.) or (C.) it comes off as rude i would say. Regarding (A.) im not 100% sure what exactly do you mean by user's site? But asking for their manager (D.) or someone else (preferably higher up) seems to be the right action to be taken.

4 0
3 years ago
Given a list of twenty number count the numbers among the list
Finger [1]

Answer:

Thank you for the points<33

7 0
2 years ago
What happens during the production stage
PSYCHO15rus [73]

Answer:

Production is where the principal photography for the movie or TV show takes place.

Explanation:

During rehearsals and camera blocking, Stand-Ins work with the Director, Assistant Director, camera crew, and other crew members to block out actor movements and lighting set-ups for a scene.

4 0
3 years ago
Individual mental blocks may cause option
Bond [772]

B. negative attitude option

3 0
3 years ago
Other questions:
  • Explain how do we combine multiple Boolean values?​
    5·1 answer
  • If i'm wanting to use hydra on linux to crack a password and the issue regarding hashes occurs, what shall i do?
    12·1 answer
  • Which of the following is a negative impact of technology on society
    9·1 answer
  • Instructions:Select the correct answer.
    6·2 answers
  • On the piano, the pitches/notes used on the bass clef are located on what part of the keyboard?
    9·2 answers
  • What is not true about contracts?
    12·2 answers
  • 1. __________ indicate a BAL of .10% or higher.
    10·1 answer
  • What would be the printed output of the Python code to the right?
    14·1 answer
  • A trial-and-error method of problem solving used when an algorithmic or mathematical approach is called
    7·1 answer
  • What does a virtual machine emulate?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!