Need Help With A Program
I have an assignment that I need help with.
I need to write a C++ program that will read data from a file, perform computation on the data, then print the result to another file. The data from the file will contian 100 lines where each line contains three items. The three items are an arithmetic operation followed by two integer values (non zero.) The program should perform the arithmetic operation specified on the two integers. Then the program should print out to another file the first number, the arithmetic operation, the second integer, an = sign, then the result of the operation just performed. This should repeat for the 100 lines. The program should compute the result by first using a switch statement to identify the operation (+, -, *, /) then call the appropriate function to perform the computation and print the result to the second file. A sample input file: + 4, 54 - 34 45 * 42 2 / 325 5 A sample output file: 4+45=50 34-45=-11 42*2=84 325/5=13 The general format of the program should be as follows: - The include section... - Declaring the file pointers ifstream infile; ofstream outfile; - The add function - The subtract function - The multiply function - The divide function - The main function
that definitely looks like a straight copy/paste from your assignment sheet.
if you dont even take the time to type/explain the assignment yourself (let alone post your attemps/errors/sample code/specific questions, etc), then i dont have time to give you an answer.
Well my group attempted this project and we don't know where to start. Please we need some help asap. PLEASE!!!!
Heh: I doubt it's a copy-paste job, 'cause that's some really bad arithmetic there.
Anyway, when all else fails, begin at the beginning. Have you worked out a flowchart, maybe, or at least some basic idea of the overall structure of your program? Does your assignment have some pointers as to what the overall structure of your program should be? (Hint: If I'm asking the question....)
We tried working on the read data file but that didn't work.
Originally Posted by vincex200
as i said, we wont help if you dont try. if youve 'tried working on the read data', then post your code and any errors if there were any given.
as tabstop said, the best thing to do is to write out pseudocode for your assignment. that is, ignore programming for the moment. get some paper and write out preciseinstructions on what needs to be done, and in what order. realize that a computer knows nothing--you need to tell it exactly what to do, step by step. so pretend the computer is a child and you need to tell it what to do, that is what you need to write down.
once you have your 'algorithm', you can start to write the code for it. at least write out the pseudocode and let us know what you have. oddly enough, coding comes second in programming.
Happy reading ;) Oh, and it's about File I/O. Might be useful to you.