The question is asking: In Frankfurt, Germany, time is six hours ahead of the U.
ID: 3628654 • Letter: T
Question
The question is asking: In Frankfurt, Germany, time is six hours ahead of the U.S. Eastern time zone. Write a program that uses the time12 class to output the time in Frankfurt that corresponds to midnight on New Year's Eve in New York City. I have gotten a start on the time12 class but am having trouble writing the program. Can I get some help? I am posting the time12 class as well.#ifndef TIME12_CLASS
#define TIME12_CLASS
#include <iostream>
#include <iomanip>
#include "d_time24.h"
using namespace std;
//specifies clock time units
enum timeUnit {AM, PM};
class time12 //client class
{
private:
time24 t;
timeUnit ttunit;
// store time in 24-hour format
time24 convert24To12(int h, int m, timeUnit tunit);
// build t from standard time
public:
time12( int h = 12, int m = 0, timeUnit tunit = AM) : ttunit(tunit){
t = convert24To12( h, m, tunit);}
// initialize time24 data member t
void addTime(int m);
//add m minutes to update current time
void readTime();
// input from the keyboard time in form hh:mm
//
void writeTime() ;
// display on the scren the current time
};
//****************************************************
// time12 class implementation
//****************************************************
time24 time12:: convert24To12(int h, int m, timeUnit tunit)
{
if (tunit == AM)
return time24(h % 12, m);
else
return time24(h % 12 + 12, m);
}
void time12::readTime()
{
char colonSeparator;
int h, m;
string clock;
timeUnit tunit;
if(clock == "AM")
cin >> h >> colonSeparator >> m >> clock;
else
tunit = PM;
t = convert24To12(h, m, tunit);
}
void time12::addTime(int m)
{
t.addTime(m);
}
void time12::writeTime()
{
long currentFlags = cout.flags();
char currentFill = cout.fill();
int hour, minute;
cout.fill('0');
cout.setf(ios::right, ios::adjustfield);
hour = t.getHour();
minute = t.getMinute();
if(hour < 12)
if(hour == 0)
{
hour = 12;
cout << hour << ':' << 'AM';
}
else
{
hour = hour - 12;
if(hour == 0)
hour = 12;
}
}
#endif
Explanation / Answer
You're going to need to provide d_time24.h before I can help you.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.