Hello. I don\'t know where to start on this one. Could you please help? Design a
ID: 3634262 • Letter: H
Question
Hello. I don't know where to start on this one. Could you please help?Design a class for a widget manufacturing plant. Assuming that 10 widgets can be produced each hour, the call object will calculate how many days it will take to produce any number of widgets. (The plant operates two shifts of eight hours each per day.) Write a program that asks the user for the number of widgets that have been ordered and then displays the number of days it will take to produce them.
Input Validation: Do not accept negative values for the number of widgets ordered.
Explanation / Answer
#include <iostream>
using namespace std;
class Widget
{
private://member variables
double now;
double nod;
public:
//Mutator function for widgets
void setWidgets(double w)
{
if(w>0)
{
now=w;
nod=now/160;
}
else
cout<<"Invalid number of widgets"<<endl;
}
//Accessor function for widgets
double getWidgets()
{
return nod;
}
};
int main()
{
Widget w;
double d;
cout<<"Enter the number of widgets"<<endl;
cin>>d;
w.setWidgets(d);
/*Calculating the number of days it takes
for given widgets number*/
cout<<"The number of days it take to produce "
<<d<<" widgets is:"<<w.getWidgets()<<endl;
system("pause");
return 0;
}//end
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.