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]
2 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]2 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
with the _______ network topology, reliability is the major advantage while high cost is the disadvantage.
Nady [450]
It's what the chat says, Its hybrid
6 0
3 years ago
Read 2 more answers
A*=++a/6+b++ 3 if a=3,b=4​
Vinil7 [7]

Answer:

a=22.5

Explanation:

Given

a*=++a/6+b++3

Required

The result when a=3 and b=4

Analyzing the given instruction

a*=(++a)/(6)+(b++3)

Single out and solve the expressions in bracket

(++a) = a -- When the ++ operator appears before an operand, it is called pre increment. meaning that the operation will be done before the operand will be incremented.

So: in this case: ++a = a

b++3 = b + 3

The operator, as used in that statement is the same as: b + 3.

So:

a*=(++a)/(6)+(b++3)

a*=(a)/(6)+(b+3)

a*=(3)/(6)+(4+3)

a*=0.5+7

a*=7.5

The above expression is calculated as:

a=a*7.5

So:

a=3*7.5

a=22.5

8 0
3 years ago
Help plzzzzzzzzzzzzzzzzzzzzzzzzz
Reil [10]

B, Parallel ports are faster than serial ports.

A parallel port can move a set of 8 bits at a time on eight different wires, it uses a 25 pin connector, called a DB-25 connector, whereas a serial port only has a DB-9 connector.

7 0
2 years ago
Trucking A. is one of the least flexible transportation modes. B. is increasingly using computers to manage its operations. C. i
saw5 [17]

Answer:

B. is increasingly using computers to manage its operations.

Explanation:

Trucking -

It refers to the practice of using computer for the management purpose , is referred to as the process of trucking .

The method is very useful for the business and companies in order to adapt a faster and efficient mode of management .

Hence , from the given information of the question ,

The correct option is b. is increasingly using computers to manage its operations.

7 0
3 years ago
Engine coolant does all of the following except
Amiraneli [1.4K]
D prevent the formation of rust
8 0
3 years ago
Read 2 more answers
Other questions:
  • Populate a one-dimensional array with the following grades in this order: 90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, an
    15·1 answer
  • How to determine if the function f(x) = x^2 + 3 from real numbers to real numbers is Injective, surjective, or bijective
    13·1 answer
  • The use of electronic media, information, and communication technologies to deliver instruction where students are not required
    8·1 answer
  • What could be one rule to help your friend to blog safely
    6·2 answers
  • Items that are cut or copied are placed on the Clipboard.
    6·2 answers
  • Deleting anitem from a linked list is best when performed using two pointersso that the deleted item is freed from memory.
    7·1 answer
  • Join zoom meet <br>id=547 458 9345<br>pw=sencHURI​
    8·2 answers
  • Help please! Coding!
    9·1 answer
  • How many bits would be needed to count all of the students in class today?There are 25 in class
    15·2 answers
  • You are the IT security administrator for a small corporate network. The HR director is concerned that an employee is doing some
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!