Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Time takes an Eastern Standard Time in hours, minntes, and seconds and prints it out in Eastern Time, Central Time, Mountian Time, or Pacific

Program Time takes an Eastern Standard Time in hours, minntes, and seconds and prints it out in Eastern Time, Central Time, Mountian Time, or Pacific Time, Again, the program compiles but the answer is wrong Correct the program describe the error, (hint: this bug is very subtle-you neef a good test plan to find it.)

// Program Time takes an Eastern standard time in hours, minutes, and seconds,

// and prints it out in Central time, Mountain time, or Pacific time.

#include

using namespace std;

enum TimeZones {EASTERN, CENTRAL, MOUNTAIN, PACIFIC};

TimeZones GetZone();

// Returns a time zone.

void PrintZone(TimeZones zone);

// Prints time zone in words.

void PrintTime(TimeZones zone, long time);

// Prints time in all four zones.

int DecrementTime(int);

int GetTime();

int main ()

{

TimeZones zone;

long time;

time = GetTime();

zone = GetZone();

switch (zone)

{

case PACIFIC : time = DecrementTime(time);

case MOUNTAIN: time = DecrementTime(time);

case CENTRAL : time = DecrementTime(time);

case EASTERN : break;

}

PrintTime(zone, time);

return 0;

}

/**********************************************************/

int DecrementTime(int time)

{

return time - 3600;

}

/**********************************************************/

int GetTime()

{

int hours;

int minutes;

int seconds;

cout << "Enter a time (EST) in hours, minutes, and seconds, "

<< "separated by blanks" << endl;

cin >> hours >> minutes >> seconds;

return seconds + minutes*60 + hours*3600;

}

/**********************************************************/

TimeZones GetZone()

{

int zone;

cout << "What time zone do you wish the time printed in?" << endl;

cout << "Enter 0 for Eastern" << endl;

cout << "Enter 1 for Central" << endl;

cout << "Enter 2 for Mountain"<< endl;

cout << "Enter 3 for Pacific" << endl;

cin >> zone;

return TimeZones(zone);

}

/**********************************************************/

void PrintZone(TimeZones zone)

{

switch (zone)

{

case 0: cout << "Eastern" << endl; break;

case 1: cout << "Central" << endl; break;

case 2: cout << "Mountain" << endl; break;

case 3: cout << "Pacific" << endl; break;

}

}

/**********************************************************/

void PrintTime(TimeZones zone, long time)

{

cout << "The time you entered is ";

cout << time / 3600 << " hours "

<< (time % 3600) / 60 << " minutes "

<< (time % 60) << " seconds ";

cout << " in ";

PrintZone(zone);

cout << " time." << endl;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

What is the yield to maturity of a bond?

Answered: 1 week ago

Question

Explain how HR serves as a strategic business partner.

Answered: 1 week ago