{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

AIIIQ3 - z.write(fout fout.close system"notepad...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <fstream> using namespace std; u class time24 { private: int hour; int minute; public: time24(int h = 0 , int m = 0); void write(ostream& out); time24 add(const time24& y); time24 minus(const time24& y); }; int main () { ofstream fout ("time24.out"); time24 x(18, 34), y(10,56), z; fout << "The time24 x is: "; x.write(fout); fout << "\nThe time24 y is: "; y.write(fout); z = 12; fout << "\nThe time24 z is: "; z.write(fout); z = x.add(y); fout << "\nThe time24 z now is: "; z.write(fout); z = x.minus(y); fout << "\nThe time24 z now is: ";
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: z.write(fout); fout.close(); system("notepad time24.out"); return 0; } time24::time24(int h, int m){ hour=h; minute=m; } void time24::write(ostream& out){ out<<hour<<":"<<minute<<endl; } time24 time24::add(const time24& y){ time24 z; int tm=minute+y.minute; z.minute=tm%60; z.hour=((hour+y.hour)+tm/60)%24; return z; } time24 time24::minus(const time24& y){ time24 z; int tm=minute-y.minute; if(tm<0){ tm=tm+60; z.hour=-1; } z.minute=tm; z.hour=z.hour-y.hour+hour; if(hour<=y.hour) z.hour=z.hour+24; return z; }...
View Full Document

{[ snackBarMessage ]}