i have made this time convertor this is my first project i am new to c++ and programming can you tell me if there is any way to write this code to be more efficient or this is code is ok. thanks for answering.
#include <iostream>
using namespace std;
int main()
{
long double value;
int input ;
int input2;
char again;
do{ //loop for using programme again
cout << "Welcome to time converter" << endl; //welcome text
cout << "========================" << endl;
cout << "Select option you want to convert" << endl;
cout << "1.Minutes" << endl;
cout << "2.Hours" << endl; //User will select what to convert
cout << "3.Seconds" << endl;
cin >> input;
while(input <1 || input >3 ){
cout << "Error : Select a valid option:" << flush;
cin >> input;
}
cout << "Select what do you want to convert" << endl;
cout << "1.Minutes" << endl;
cout << "2.Hours" << endl; //User will select in which he wants to convert
cout << "3.Seconds" << endl;
cin >> input2;
while(input2 <1 || input2 >3 ){
cout << "Error : Select a valid option:" << flush;
cin >> input2;
}
while(input ==1 && input2 ==1 ){
cout << "Error : Select a valid option:" << flush; //if user accidentally slects same option in both menu
cin >> input2;
}
while(input ==2 && input2 ==2 ){
cout << "Error : Select a valid option:" << flush;
cin >> input2;
}
while(input ==3 && input2 ==3 ){
cout << "Error : Select a valid option:" << flush;
cin >> input2;
}
if(input ==1 &&input2 ==2){
cout << "Enter number of Minutes you want to convert in hour: " << flush;
cin >> value;
cout << endl;
cout << "Result:" << value/60 << " " << "hours"<< endl;
}else if(input ==1 &&input2 ==3){
cout << "Enter number of minutes you want to convert in seconds: " << flush; 2
cin >> value;
cout << endl;
cout << "Result:" << value*60 << endl;
}else if(input ==2 &&input2 ==1){
cout << "Enter number of hours you want to convert in minutes: " << flush;
cin >> value;
cout << endl;
cout << "Result:" << value*60 << " "<< "minutes" << endl;
}else if(input ==2 &&input2 ==3){
cout << "Enter number of hours you want to convert in seconds: " << flush;
cin >> value;
cout << endl;
cout << "Result:" << value*3600 << " "<< "seconds" << endl;
}else if(input ==3 &&input2 ==1){
cout << "Enter number of seconds you want to convert in minutes: " << flush;
cin >> value;
cout << endl;
cout << "Result:" << value/60 << " "<< "minutes" << endl;
}else if(input ==3 &&input2 ==2){
cout << "Enter number of seconds you want to convert in hours: " << flush;
cin >> value;
cout << endl;
cout << "Result:" << value/3600 << " "<< "hours" << endl;
}
cout << endl;
cout << "Press Y to use the programme " << endl;
cout << "Press N to exit" << endl;
cin>> again;
}while( again =='y'|| again =='Y');
cout << "Programme ended" <<endl;
return 0;
}