64 735
Assignments Done
99,3%
Successfully Done
In September 2018

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
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions