0% found this document useful (0 votes)
36 views1 page

Using Namespace Class Public Int Public Void Void Void: #Include #Include

This C++ program defines a Time class with member variables for minutes, hours, and an input time. The get_data() method prompts the user to enter a time in 24-hour format and calculates the equivalent minutes and hours. The display() method calls get_data(), outputs the input time converted to minutes and hours, and displays the time as either AM or PM depending on the hour value.

Uploaded by

Farhana Ariffin
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views1 page

Using Namespace Class Public Int Public Void Void Void: #Include #Include

This C++ program defines a Time class with member variables for minutes, hours, and an input time. The get_data() method prompts the user to enter a time in 24-hour format and calculates the equivalent minutes and hours. The display() method calls get_data(), outputs the input time converted to minutes and hours, and displays the time as either AM or PM depending on the hour value.

Uploaded by

Farhana Ariffin
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

CODING TIME #include <iostream.h> #include<conio.

h> using namespace std; class Time{ public: int minutes, hour, input, baki; public: void get_data(); void display(); }; void Time::get_data(){ cout<<"\nInsert time (in 24hours format) : "; cin>>input; minutes=input*60; hour=minutes/60; } void Time::display() { get_data(); cout<<"\nCALCULATION HOUR INTO MINUTES "<<endl<<endl; cout<<input<<" x "<<" 60 = "<<minutes<<" minutes "<<endl<<endl<<endl; cout<<"\nCALCULATION MINUTES INTO HOUR "<<endl<<endl; cout<<minutes<<"/60 = "<<hour<<" hour"<<endl<<endl<<endl; if(hour<12) { cout<<"\nTHE TIME IS : "<<hour<<" am "; } else if(hour>12) { baki=hour-12; if(baki<6) { cout<<"THE TIME IS : "<<baki<<" pm"; } else { cout<<"THE TIME IS : "<<baki<<" pm"; } } } int main(){ Time a; a.display(); }

You might also like