English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

ok, so i have to write a program that takes in the current date and the date of the expiration of a food product in the form of mm/dd/yyyy

then i have to make 3 bool functions that do no input from the keyboard nor output to the screen. they do only logic.

those three bool functions are 'isvalid' which is true if the date is a valid date and false if otherwise. the other bool function is 'thesame' which is true if the two dates are the same and false otherwise. and the last bool function is called 'earlier' which is true if the 1st date (the expiration date) is earlier than the 2nd date (the current date)

i already made the functions, but then at the end of the program, i have to have the program either say 'the dates are the same', 'expiration date/current date is not valid', 'the expiration date is earlier than today', or 'the expiration date is later than today'

but i have no idea how to make my program put those outputs out. i have to use 'if' statements, please help!

2007-03-20 12:54:25 · 2 answers · asked by 63godtoh 3 in Computers & Internet Programming & Design

icnintel, i havent the slightest clue of what your talking about

please, if you can, better yet if you get this message, can you explain it a little better than that?

i am in computer science 115, this is an intro to C++, i dont know much, only very very basic, and only some of that

i have to use 'if' statements to put those outputs i said at the end of my question from before

i dont know what ofstream is or how to get a text file or whatever that was, and we cant use what we havent been taught, and we havent been taught that stuff, so i can't use it, even if it works

please, if you can think of some way of using 'if' statements to get those outputs i want or some other easier way than that i would be very thankful

2007-03-20 13:35:00 · update #1

coosa, idk if you got the point i was trying to get across the last time you answered one of my questions, but nothing you are saying is of any use to me because i can not use anything your talking about

i am in a class, and our teacher does not want us using anything that we have not gone over in class. and, again, the things you are saying all are of no use to me

i cant use tokenizing, vectors or arrays, so everything your saying is not helping. please stop going on and leaving more messages for me when i cant understand or use any of it. there really is no point in it really

so please, unless you know how i can make an output to read a sentence that i make up like 'the dates are the same' based on three different BOOL functions i have, THAT I MUST KEEP AND CAN NOT CHANGE (and these bool functions only return true or false, nothing else), then dont carry on with a bunch of other stuff that i can not use, it really is just wasting your time and mine.

2007-03-20 14:21:04 · update #2

icnintel, thank you, your the only person on this site that has so far found a way to correctly answer one of my questions the way i needed it to be answered

and sorry if i seemed like i was making it to hard, its just im sure there are like a million easier ways to do this but if i use something that we have not gone over in class, even if it works, she will count it wrong

and its been hard to get people to understand that i cant use a lot of different techniques and that i have to stay in C++

sorry if i seemed like an ***, i just get so mad on this site so easily because of no one ever giving a response i want

2007-03-20 14:45:36 · update #3

2 answers

If you're doing all this, then surely you know basic input and output...use cout << "blah blah" << endl; or output << "blah blah" << endl; where output is an ofstream object that points to a text file.

Um, I'm talking about basic input and output, probably the first and second things they teach you:

string name;
cout << "enter you name:" << endl;
cin >> name;
cout << "nice to meet you, " << name << endl;

If you can't use ofstream then just use cout...pretty simple.

You're making this too complicated:

if(isvalid(date))
cout << "valid" << endl;
... etc.

2007-03-20 13:27:11 · answer #1 · answered by Anonymous · 0 0

EDIT:
Explain what EXACTLY have you taken in your course to be included in a solution! What's not mentioned means to be excluded by default (as arrays if you don't mention them)
Example:
Datatypes: .....
Selection: if, case
OOP: Classes, Inheritance ...etc.

From your previous post, we're done explaining how to extract the data from the input;
remember my last post, you get a vector of tokens;
index 0 contains the month
index 1 contains the day and
index 2 contains the year
when you compare, you compare first the year, if the year is less, then the date is earlier, else you compare the month if the year is the same, if the month is the same, you finally go to compare with the day; the logic is simple.
I can see that you are beginning and using vectors wouldn't do you good if you are not familiar with arrays.
Again ...
Same .. you compare a string to string and no need to check the tokens
if they are not the same, then you begin tokenizing in such you start comparing with yyyy then mm then dd.
Draw your logic in a Flowchart, that's how I started programming from my lecturers to concentrate more on the logic rather than memorizing code.
Google for "C++ Tutorial" and look there for "selection" and conditions for how to use if statements.

Good luck

2007-03-20 13:55:31 · answer #2 · answered by Coosa 2 · 0 0

fedest.com, questions and answers