- 1

My 3rd problem

2nd May 2018, 4:57 PM
annouar
annouar - avatar
5 Respuestas
+ 3
Please show your code and tell us where you need help to receive useful answers.
2nd May 2018, 5:20 PM
Tashi N
Tashi N - avatar
+ 1
this is c++ please convert this to java #include <iostream> #include <conio.h> using namespace std; class time{ private: int hours,minutes,seconds; public: time(){ hours = minutes = seconds = 0; } time(int h, int m, int s){ hours = h; minutes = m; seconds = s; } void showTime() const { cout << hours << ':' << minutes << ':' << seconds; } void addTime(time x, time y){ seconds = x.seconds + y.seconds; if(seconds>59){ seconds-=60; minutes++; } minutes += x.minutes + y.minutes; if(minutes>59){ minutes-=60; hours++; } hours+=x.hours+y.hours; } }; int main(){ const time a(2,23,45), b(4,25,15); time c; c.addTime(a,b); c.showTime(); }
2nd May 2018, 5:49 PM
annouar
annouar - avatar
0
Is this your homework or something and if so asking for answers is not going to teach you it's just enforcing cheap tactics that doesn't add to learning.
2nd May 2018, 5:05 PM
Don
Don - avatar
0
Hi can you make the same code but making - opertaor overloading and + operator to add hours and thanks in advance
9th Feb 2021, 10:13 AM
ProDina Ahmed
ProDina Ahmed - avatar
- 2
Create a class called Time that has separate int member data for hours, minutes, and seconds. One constructor should initialize this data to 0, and another should initialize it to fixed values. Another member function should display it, in 11:59:59 format. The final member function should add two objects of type Time passed as arguments. A main () program should create two initialized Time objects and one that isn’t initialized. Then, it should add the two initialized values together, leaving the result in the third Time variable. Finally it should display the value of this third variable.
2nd May 2018, 4:58 PM
annouar
annouar - avatar