Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:

Project 02 Materials / C07_P02_Requirements

.docx
Скачиваний:
21
Добавлен:
14.10.2016
Размер:
1.33 Mб
Скачать

project 02: floating point calculator

Application Development

Overview

To successfully complete Project 2 please expand the code for the Integer Calculator solution into a program that properly functions as a floating-point calculator. This means:

Develop a Floating Point Calculator capable of addition, subtraction, multiplication and division of two floating point numbers.

Modify the source file comments in your calculator program so it is clear that this project is yours, while still recognizing the work of the original author.

Test the program and document the results.

Calculator Input

The floating point calculator program requires you to enter valid floating point values. The only valid values that may be placed into the two input operand fields are valid floating-point values (positive or negative) in either normal decimal notation or scientific. As long as there are no input errors the user may press one of the calculation buttons ( + or - or * or / ) to produce a result. The program will not allow you to enter data directly into the result text field. Figure 1 shows the user interface.

Figure 1: The user interface

Calculator Output:

When both entered operands are valid, the four operator buttons function as expected and the result is computed and placed into the Result field, as shown in Figure 2.

Results can be copied from the Result field and pasted into some other document, but the user is not allowed to edit the value in the Result field.

Change the word “Result” to “Sum”, “Difference”, “Product”, or “Quotient” depending upon which operator button has been pressed. As soon as any character is added or removed from either of the two operand input fields, the result must be cleared and the word “Result” must once again appear to the left of the result output field.

Please note that in Figure 2 the word “Result” has been replaced by “Product” to indicate that the multiply button was pressed to create this result.

Figure 2: The Floating Point Calculator showing the result of multiplying the two operands

If the entered operands are not valid, then the program will display error messages as shown in Figure 3.

Figure 3: The user interface showing input errors

The program displays other errors, but it is up to you to discover these errors by looking through the program source code and finding them.

©iCarnegie - Distribution or copying without permission is prohibited.

Соседние файлы в папке Project 02 Materials