Prompt the user to enter a date in the YYYYMMDD format. Example: 10 March 2010 is 20100310.
Read the user input into a variable.
Print an error message and exit the program if the user enters a negative number.
Split the YYYYMMDD number into its respective YYYY, MM, DD pieces using integer division and the modulus operator. [hint: 20100101 / 10000 = 2010 and 20100101 % 10000 = 101]
Print a line that has the following format.
YYYYMMDD is MM/DD/YYYY
examples...
20100314 is 3/14/2010
19571105 is 11/5/1957
20380118 is 1/18/2038
Your source code file must contain a file comment block. In addition, you need to turn in a printed copy of the output generated by your program for at least three different inputs.
This is my assignment and my question is same thing that was last week.. I couldn't type printed copy of my output..?
#include <iostream>
usingnamespace std;
int main()
{
int currentdate, day, month, year;
cout << "Please enter a date in YYYYMMDD format (Example: 10 March 2010 is 20100310): ";
cin >> currentdate;
day = currentdate % 100; // getting date
month = ( currentdate / 100 ) % 100; // Month
year = ( currentdate / 10000 ); // getting year
if ( currentdate < 0 || day < 0 || month < 0 || year < 0 )
{
cout << "***Error...Please enter positive numbers" << endl;
exit(1);
return 0;
}
cout << currentdate << " is " << month <<" / " << day <<" / " << year <<endl;
system("pause");
return 0;
}
I couldnt type thıs part...
Your source code file must contain a file comment block. [b]In addition, you need to turn in a printed copy of the output generated by your program for at least three different inputs.
A file comment block is probably meaning a large comment at the top of the file that describes the file, gives the author's name, etc. The output just means your professor also wants you to run your program and input several different numbers and include them with your program as examples.
Your file comment block looks fine to me, though you may want to check any guidelines you professor has given for what it needs to contain.
As for your output, you don't need to include it in the code itself; I'd just have a separate text file with the output in it to be turned in with your assignment. Again, you professor probably has some guidelines as to what exactly they want. I'd expect they basically want you to show the entire program output for inputting three different numbers.