Answer to Question #204140 in C++ for harshitha p

Question #204140

consider two classes , hours and minutes . write a program to convert the hours to minutes using class to class type using both constructor and conversion function method


1
Expert's answer
2021-06-07T11:36:43-0400
#include<iostream>
using namespace std;

class Hours{

public:
    //Default constructor
    float hours,minutes, seconds;
    Hours(float hours){
    this->hours=hours;

    }
    float getHoursToMinutes(float n){
    minutes = n * 60;
    return minutes;
    }
    float getHoursToSecond(float n){
    seconds=n*60*60;
    return seconds;
    }

};
class Minutes{
float minutes, seconds;
public:
    Minutes(float minutes){
    this->minutes=minutes;

    }
    float getMinutesToSecond(float n){
    seconds=minutes*60;
    return seconds;
    }

};

int main(){

cout<<"Conversion of hours to minutes and seconds"<<endl;
Hours h(60);
Minutes m(45);
cout<<h.getHoursToMinutes()<<endl;
cout<<m.getMinutesToSecond<()<endl;


return 0;}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog