SlideShare una empresa de Scribd logo
1 de 2
In C++ please help with the following
Time Clock
Design a class namedTimeClock. The class should be derived from theMilTime class
you designed in Programming Challenge 4. The class should allow the programmer to
pass two times to it: starting time and ending time. The class should have a member
function that returns the amount of time elapsed between the two times. For example,
if the starting time is 900 hours (9:00 am), and the ending time is 1300 hours (1:00
pm), the elapsed time is 4 hours.
Input Validation: The class should not accept hours greater than 2359 or less than 0
Solution
class TimeClock: public MilTime
{
public:
int startinghrs endinghrs, timeelapsed;
void getTimeElapsed()
{
cout<<"Enter starting time"<<endl;
cin>>startinghrs;
cout<<"Enter ending time"<<endl;
cin>>endinghrs;
if(startinghrs<0 && startinghrs>2359 && endinghrs<0 && endinghrs>2359)
{
cout<<"Invalid times";
}
else
{
timeelapsed = endinghrs - startinghrs;
cout<<"The time gap is "<<abs(timeelapsed);
}
};
// header files iostream.h, cstdlib.h, climits.h
}

Más contenido relacionado

Más de tristans3

In a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docxIn a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docxtristans3
 
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docxIn consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docxtristans3
 
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docxIn chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docxtristans3
 
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docxIn certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docxtristans3
 
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers  Why do they call it dereferencing- As in derefer.docxIn c- Topic pointers  Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers Why do they call it dereferencing- As in derefer.docxtristans3
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxtristans3
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxtristans3
 
In an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docxIn an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docxtristans3
 
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docxIn a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docxtristans3
 
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docxIn a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docxtristans3
 
In 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docxIn 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docxtristans3
 
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docxIn 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docxtristans3
 
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docxIn 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docxtristans3
 
Impulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docxImpulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docxtristans3
 
Implementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docxImplementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docxtristans3
 
Implementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docxImplementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docxtristans3
 
Im creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docxIm creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docxtristans3
 
ii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docxii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docxtristans3
 
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docxIMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docxtristans3
 
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docxtristans3
 

Más de tristans3 (20)

In a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docxIn a symmetric multiprocessor configuration- AH processors can perform.docx
In a symmetric multiprocessor configuration- AH processors can perform.docx
 
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docxIn consumer behavior we discussed innovators- opinion leaders- and mar.docx
In consumer behavior we discussed innovators- opinion leaders- and mar.docx
 
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docxIn chapter 2- 5 objectives of memory management were discussed- In Cha.docx
In chapter 2- 5 objectives of memory management were discussed- In Cha.docx
 
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docxIn certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
In certain chlorophyll cofactors the Mg2+ is axially coordinated by th.docx
 
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers  Why do they call it dereferencing- As in derefer.docxIn c- Topic pointers  Why do they call it dereferencing- As in derefer.docx
In c- Topic pointers Why do they call it dereferencing- As in derefer.docx
 
In C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docxIn C++ a function used to put data into a stack is typically called a.docx
In C++ a function used to put data into a stack is typically called a.docx
 
In C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docxIn C Programming create a program that converts a number from decimal.docx
In C Programming create a program that converts a number from decimal.docx
 
In an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docxIn an alternative universe- all rules governing quantum numbers and th.docx
In an alternative universe- all rules governing quantum numbers and th.docx
 
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docxIn a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
In a nonpolar covalent bond--- Electrons are shared unevenly Electrons.docx
 
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docxIn a Classical model of the macroeconomy- the equilibrating mechanism.docx
In a Classical model of the macroeconomy- the equilibrating mechanism.docx
 
In 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docxIn 2012- Shurtleff estimates that warranty costs in the following year.docx
In 2012- Shurtleff estimates that warranty costs in the following year.docx
 
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docxIn 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
In 2000- June- A 75-year-old widow- creates an irrevocable trust namin.docx
 
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docxIn 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
In 2007- Heuy-'s actual income was $70-000- equal to his lifetime annu.docx
 
Impulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docxImpulse and momentum are two two different parameters- Explain these p.docx
Impulse and momentum are two two different parameters- Explain these p.docx
 
Implementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docxImplementation of EHR Discuss the advantages and disadvantages associa.docx
Implementation of EHR Discuss the advantages and disadvantages associa.docx
 
Implementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docxImplementing a new AIS system could prove to be beneficial or detrimen.docx
Implementing a new AIS system could prove to be beneficial or detrimen.docx
 
Im creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docxIm creating a stack class using generics- what should my peek method l.docx
Im creating a stack class using generics- what should my peek method l.docx
 
ii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docxii)State whether you would expect the following Group 13 metal cations.docx
ii)State whether you would expect the following Group 13 metal cations.docx
 
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docxIMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
IMF in Greece- Good or bad for the country- Why-SolutionIMF is interna.docx
 
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
2- What is a colloid- Why is it difficult to filter a colloid- 3- What.docx
 

Último

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 

Último (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 

In C++ please help with the following Time Clock Design a class namedT.docx

  • 1. In C++ please help with the following Time Clock Design a class namedTimeClock. The class should be derived from theMilTime class you designed in Programming Challenge 4. The class should allow the programmer to pass two times to it: starting time and ending time. The class should have a member function that returns the amount of time elapsed between the two times. For example, if the starting time is 900 hours (9:00 am), and the ending time is 1300 hours (1:00 pm), the elapsed time is 4 hours. Input Validation: The class should not accept hours greater than 2359 or less than 0 Solution class TimeClock: public MilTime { public: int startinghrs endinghrs, timeelapsed; void getTimeElapsed() { cout<<"Enter starting time"<<endl; cin>>startinghrs; cout<<"Enter ending time"<<endl; cin>>endinghrs; if(startinghrs<0 && startinghrs>2359 && endinghrs<0 && endinghrs>2359) { cout<<"Invalid times"; } else { timeelapsed = endinghrs - startinghrs; cout<<"The time gap is "<<abs(timeelapsed); } };
  • 2. // header files iostream.h, cstdlib.h, climits.h }