| |
|
|
Buyer Summary:
|
| |
| Username: |
|
| Feedback Score: |
        
1
reviews
|
| Award Reliability: |
1 posted 1 paid |
| |
|
| Location: |
Sydney, NSW, Australia
|
| Member Since: |
June 16, 2008 |
| |
|
|
|
| Invited Users: |
There are no invited users
|
Description
Objectives: This assignment aims to review C++ skills or concepts including: C++ classes Separate compilation Stacks Command-line arguments Reading from a file Task: A Calculator Program In this project, you will write a program that acts as a simple calculator. Description This program will be reading a file that contains an arithmetic expression on each line. The program evaluates these expressions and prints the values to cout. The expressions will be postfix expressions (as described on pages 373--376 of the text). Your program will be implemented using a stack-based algorithm for evaluating an arithmetic expression.
Getting Started Read all of Chapter 7, with particular attention to Section 7.4. To help you get started, the following files will be supplied:
the stack header file stack2.h the stack template file stack2.template the node header file node2.h the node template file node2.template N.B.Your program must use this startup files in its implementation This project requires you to read a file, specified in the command line arguments when the program is executed, and output the resulting answers to cout.
The input expressions contained in the file will be postfix expressions. Use the evaluation algorithm from Figure 7.10 on page 376 of the text.
Additional Functions Include the following three functions in your implementation A function that opens a file for input and checks that the opening process did not fail. The specification for this function is: void open_for_read(ifstream& f, const char filename[ ]); // Postcondition: The ifstream f has been opened for // reading using the given filename. If any errors // occurred then an error message has been printed // and the program has been halted.
A boolean function that determines whether a specified file still has valid input. The specification is: bool is_more(istream& f); // Postcondition: The return value is true if f still has // more valid input to read; otherwise the return // valid is false.
Notice that the data type of the argument is an "istream" rather than an "ifstream". An istream is usually an ifstream, although later you will learn of other kinds of istreams (such as cin). Istream arguments must always be reference parameters.
A function named process_line with this prototype: void process_line(istream& f, bool& okay, double& answer);
One useful technique that you might use when you first start to implement this function is to firstly implement a simple version of the process_line function. The simple version reads one input line, sets okay to true, and sets answer to 42.0 (Later you will implement a more complex version of the function that actually evaluates an arithmetic expression from the input line). Put the simple version in your source code and change the body of the main function so that it does this: Declares an ifstream variable called input and uses open_for_read to open input for reading. Use argv[1] as the name of the input file. Have a loop that continues while there is more input. In the body of the loop, call process_line. If process_line sets okay to true then print the value of answer on the next output line; otherwise print the word INVALID on the next output line. Close the input file and print a message saying that the program is done. The possible errors that will cause okay to be set to false: (a) division by zero, (b) an operation symbol is read but the stack does not have at least two numbers, (c) the entire expression has been read and evaluated but the numbers stack does not have exactly one number on it.
If an error is detected, be sure to continue to read the rest of the input line (up to and including the newline character). Use input techniques similar to those in Figure 7.5 on pages 361-362.
Reminder
You may not start working in this and any request before
your bid is accepted. Users who violate this policy
may have their accounts permanently suspended.
|
|
|
|
| |
| Get the Free
Step-by-Step Guide on How to Use GetACoder |
The act of
outsourcing jobs has become easy in the past few years
thanks to GetACoder. However, our team aims at making the
whole process even easier. So, it has now come the time to
provide you with a step-by-step guidance on how to use this
service and succeed in the outsourcing world totally for
FREE.
It doesn't matter if you are a more experienced user or a
novice; using GetACoder will become even simpler with the
help of this E-book. There are two major sections: a Buyers
section and a Coders section.
Buyers will learn:
- How to outsource safely
- How to pick the best freelancers
- How to manage time and money
Coders will learn:
- How to get the best jobs
- How to secure their payments
- How to build a long-lasting relationship with buyers
...and MUCH MORE
Clear examples and pictures illustrating key situations,
great tips and real testimonies of some of our best users...
all in this Outsourcing Guide. So don't loose the
outstanding opportunity to download GetACoder FREE E-book.
|

 |
|
GetACoder is a leading Global Services Marketplace doing business in more than 200 countries. Our unique system accelerates your time to market and provides your business with key competitive advantages. When you use GetACoder you are stretching your budget and saving as much as 60% over traditional outsourcing. GetACoder is changing business, now it's no longer about what you own or build but which resources and talent you can access. With GetACoder you reduce expenses, increase efficiencies, aggressively grow your business, and create a sustainable competitive advantage. GetACoder makes outsourcing to any part of the world an easy task! With GetACoder it's simple to outsource any business request, gain access to global talent and manage jobs online. One of the main advantages of GetACoder is the low labor cost. The typically rates are about seven times lower than the ones in the US or Europe. Posting a request at GetACoder allows the right professional or company to find you and to bid for your work. We are building a reputation for exceeding our customers' expectations and for becoming an extremely cost effective way to outsource work. Use GetACoder when you want to save money, increase efficiency or accelerate the development of your request. With GetACoder you focus on growing your business and let others do the tedious work. Post your request on GetACoder for free. Find out why people outsource jobs with us day after day. Thousands of Satisfied Customers - Submit/View Quotes
| - | I found GetACoder to be one of the best freelancer sites. It's really a great place where any organization can get a great mind to complete projects. GetACoder is simply great! - | | - | First experience using GetACoder.com and I'm really surprised and impressed. Dr. S.Ali - | | - | GetACoder changed my life. - |
|
|
| |
© 2004-2012 GetACoder. All rights reserved. |
|