i want the code in C++ using the visual studio program . Object Orientated Progr
ID: 3576260 • Letter: I
Question
i want the code in C++ using the visual studio program .
Object Orientated Programming
reflect an object orientated model for programming.
Use Constructors, Parameters, and arguments as needed.
Write a program that has 2 methods.
1 method will convert Seconds into minutes.
1 method will convert seconds to hours, minutes, and seconds
Use the modulus arithmetic symbol for part of the calculation/conversion if you like.
Output= Show number of seconds, conversion to minutes, and remaining seconds.
or
Show number of seconds, converted to hours, converted to minutes, and remaining seconds.
Attach Source Code photo
Attach output of both methods being run.
Explanation / Answer
#include <iostream>
using namespace std;
class secondsConversion
{
public:
int seconds;
void secondsToMinutes(int seconds)
{
int minutes;
minutes = seconds / 60;
cout << " " << seconds << " seconds is equivalent to " << int(minutes) << " minutes " << int(seconds%60) << " seconds.";
}
void secondsToHoursAndMinutes(int seconds)
{
int hours, minutes;
minutes = seconds / 60;
hours = minutes / 60;
cout << " " << seconds << " seconds is equivalent to " << int(hours) << " hours " << int(minutes%60)
<< " minutes " << int(seconds%60) << " seconds.";
}
};
int main() {
secondsConversion obj;
cout<<"Enter seconds :";
cin>>obj.seconds;
obj.secondsToMinutes(obj.seconds);
obj.secondsToHoursAndMinutes(obj.seconds);
}
OUTPUT:
Enter seconds : 134515010
134515010 seconds is equivalent to 2241916 minutes 50 seconds.
134515010 seconds is equivalent to 37365 hours 16 minutes 50 seconds.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.