Click here to Skip to main content
15,897,891 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Given a date of format DD MM YYYY where YYYY >= 2000, write a C++ program to:
1. Find the next date (you may ignore the special case of leap years).
2. Calculate your age up to the given date.
3. Check if the same date DD MM has passed or not in the current year. If not calculate how many days
are left.
Your program must validate the given date and display an appropriate message if it is not valid.
You must submit:
1. A MS-Word document containing the 5-steps Engineering Problem Solving Methodology as it is
applied for the above problem (name this file as hw2_99999.doc where 99999 is replaced by your
ID#)
2. A C++ program (name this file as hw2_99999.cpp where 99999 is replaced by your ID#) to do the
above tasks. The program must satisfy the following:
a. Includes necessary comments (Note: include your Name and ID on the top of the program)
b. Uses proper programming styles (e.g. spacing, indentation, variable naming, constants, …etc)
c. Clear input/output prompts which help the user to interact with the program
Posted
Updated 13-Mar-12 2:28am
v3
Comments
Sergey Chepurin 12-Mar-12 18:43pm    
If you have no idea where to start from, search Internet for a Date class implementation (should help you to "validate the given date and display an appropriate message if it is not valid"). Julian date format can help you to calculate "how many days are left". But you should start with something by yourself.

Well... start coding and when you get stuck in something concrete, ask what you are having problems with.

We could help you, but that would be worthless for you, since you were not doing what you are supposed to do with homeworks. That is... learning.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 12-Mar-12 20:25pm    
Agree, my 5. My answer goes in a similar way, please see.
--SA
Ghaida\7 13-Mar-12 5:48am    
#include<iostream>
using namespace std;
int main();
{
then ? i really suck in c++ ><
Nelek 13-Mar-12 13:59pm    
Well, this is the main reason of homeworks, to improve your skills. On the other hand... if you are so self-critical... I wonder if you maybe were happier stuying another thing (and no offense, just a thought). Sometimes is good to stop, see around and decide where the next step must go, and sometimes it is better to undo a step and change direction in order to continue advancing.
Ghaida\7 13-Mar-12 14:39pm    
"to improve your skills " and lose marks easily ...
"self-critical " in 2 courses physics and c++ only :\
anyway thanks for the advice it's not that i didn't try i did but i still don't get it
May be a clue will help :p

Try to look on SYSTEMTIME, CTime and CTimeSpan.

and as Neleck said to you, when you ll get stuck pepole will help.
 
Share this answer
 
Comments
Ghaida\7 13-Mar-12 5:45am    
what if i got stuck from the beginning ?
the problem is that i didnt get the whole idea :|
It looks like you did not really got to the idea of the value of home assignment, not yet. Here is a hint for your: home assignments are very valuable. If you have to pay for education, please understand: this is perhaps most valuable part of your school activity worth paying for. If you do not do your home assignment 100% by yourself, this is the same as flushing money down the toiled. And you don't want it.

So, I suggest we give you another chance to use the opportunities your school gives you.

Good luck,
—SA
 
Share this answer
 
Comments
Stefan_Lang 13-Mar-12 10:52am    
A crude but very concise way of putting it :D
Have a 5!
Sergey Alexandrovich Kryukov 13-Mar-12 13:18pm    
Thank you, Stefan.
By the way, this is a copy of my other answers where couple members called it very correct and polite... :-)
--SA
I don't know what that 5-steps Engineering Problem Solving Methodology is that is mentioned here, or at least not by that name (probably I know quite a few more steps ;)). Anyway, I think that is what you should be starting with!

...

Now, if you still don't know where to start, here's what I would do:

Clarification of the requirements
If this were a real world assignment, the first thing I'd do is go to the client and clarify some ambiguities, such as what exactly is meant to be the input, output, and user interaction mentioned in the very last sentence (and never before, except for the message in case of an invalid date). Of course, with a bit of common sense, you can fill in those blanks, but my experience tells me that what *you* think is obvious, and what a client thinks, are often quite different ;)

Now, this being a homework task, we'll assume it's far from reality and therefore it's safe to assume that common sense will be sufficient, i. e.

1. the input is to be a string, representing a date, and the expected format is 'DD MM YYYY'.

2. the output is supposed to consist of the results you generated from that input

3. the term 'interaction' indicates the user will be able to control the program in some way, and that usually implies a bit more than starting and responding. This part is rather vague, but two trivial operations come to mind:
a) correcting input, i. e. if your program recognizes the format of the date, or the date itself to be inappropriate, the user gets the opportunity to correct it (i. e. reenter the date)
b) repeat the operation, i. e. you let the user reenter another date

Since both operations are pretty much the same, it's probably a good idea to just put a loop around your main I/O and processing, and you need to provide a way for the user to exit the program.

Create a rough prototype
Now you have a simple layout for your program:

C++
bool one_more_try = true;
do {
   input();
   if (valid_input()) {
      process_results();
      output();
   }
   one_more_try = query_repeat();
} while (one_more_try);


Delegate the hard work (to students as homework ;p)
Of course, you need to declare and implement the individual functions used here, add function arguments and return values as needed, add comments and maybe add some initialization and clean up code (although I don't see anything here, it's always a good idea to at least check such things: I usually at least add a temporary TODO comment, in case I think of something later)
 
Share this answer
 
Comments
Ghaida\7 13-Mar-12 11:17am    
thank you :) i will try to solve it
Stefan_Lang 13-Mar-12 11:29am    
P.S.: I just realized I completely neglected the '++' part in my response. If you haven't thought of that already, a class for 'date' seems the obvious thing to do here (at least to me). You'll find that most of the functions in the loop above could be implemented as member functions of such a class.
i will sdjfjdfkjgsdufbdsvfsdghbhedfsdjb can u please help me this time only ! i have to submit it in less than 3 hours
i started with :


#include<iostream>
using namespace std;

int main ()

{
int DD,MM,YYYY ;
string strmonth;

do{
cout << "Please enter a date in the format of (DD MM YYYY): ";
cin >> DD>>MM>>YYYY;
}
if (YYYY>=2000)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900