Answer to Question #23784 in C++ for EMMANUEL

Question #23784
write a program which inputs a date in the format dd/mm/yy and outputs it in this format ;month,dd,yy : for example 25/12/61 becomes December 25, 1961
1
Expert's answer
2013-02-06T08:04:49-0500
#include <iostream>
#include <string>

using namespace std;
int main(){
cout<<"Enter? please a date in the format dd/mm/yy \n";
string date;
cin>>date;
string temp;
temp += date[0];
temp += date[1];

int dd = atoi(temp.c_str());

temp.clear();

temp += date[3];
temp += date[4];

int mm = atoi(temp.c_str());

temp.clear();
temp += date[6];
temp += date[7];

int yy = atoi(temp.c_str());

temp.clear();

string months[12] = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

cout<<"The data is - " << months[mm-1] << ' ' << dd ;
if (yy<14) cout<<", 20"<<yy<<endl;
else cout<<", 19"<<yy<<endl;

system("pause");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS