0

Here's what I'm trying to do:

Write a working C++ program that implements the following requirements:
- Develop a CALCULATOR in C++
- Implement at least six distinct arithmetic functions
- Allow for at least two functions to be combined
- Validate user input: do not allow invalid input
- Allow for a session of operations, that is, multiple operations (--> loop; track at least 10 operations)
- User variables of types appropriate for the arithmetic function implemented
- Write out up to last 10 operations to a text file
- Comment you code properly
- Provide a pleasant, aesthetic user interface and useful error messages

I created a 6 function calculator, but I did it using ints and doubles as my variables. Since I have to write the results to a text file, should I use strings and parse for numbers and operators instead? And should I use a for loop to track the operations? Thanks for any info.

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jonsca
0

To write the operations to a file, open up a filestream object, fout, and I would simply direct your operations into it as you go.
When the user hits plus, fout <<" + "; Unless you wanted to wait until the end of the line to make sure the user doesn't press clear or something. In that case you could keep concatenating the operations onto a string: calculation+=" +" ; at the end of the line, fout <<calculation<<endl;

Edited by jonsca: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.