Hello,
I am trying to create a time conversion calculator and I think I have it down but I do not know how to get it to display just one answer per selection. Like I can select 1 and it shows results for 1 and 2 . . or I can select 3 and it says program terminated and it also shows results for 2. I'm sure it's something simple but I can't figure it out . . please help?
Thank you!
/* Specification:
This converts time */
#include <iostream>
using namespace std;
namespace time{
enum menuOptions {Minutes, Hours, Seconds, Modulus, Exit};
}
int main (){
//ask the user for minutes
const int timeCalc = 60;
int minutes = 0;
int hours = 0;
int seconds = 0;
int modulus = 0;
cout << endl << "Welcome to the Time Conversion Calculator!\n";
cout << endl << "Enter minutes: ";
cin >> minutes;
cout << endl << endl;
//ask the user for desired conversion method
int convMeth = 0;
cout << "Choose a conversion method:\n\n";
cout << time::Hours << " - Minutes to hour(s) and minutes\n";
cout << time::Seconds << " - Minutes to seconds\n";
cout << "Make your selection: ";
cin >> convMeth;
//perform calculations and output result
if (convMeth < 1 || convMeth > 2)
{
cout << endl << "Invalid choice - program terminated\n\n";
}
if (convMeth == 1)
{
hours = minutes / timeCalc;
modulus = minutes % timeCalc;
cout << endl << "Result: " << minutes << " minutes equals " << hours << " hour(s) and " << modulus << " minutes. \n\n";
}
if (convMeth = 2)
{
seconds = minutes * timeCalc;
cout << endl << "Result: " << minutes << " minutes equals " << seconds << " seconds. \n\n";
}
cout << endl << endl << "end of program\n\n";
return 0;
}