Java using Eclipse IDE for Java developers

[et_pb_section fb_built="1" specialty="on" _builder_version="4.9.3" _module_preset="default" custom_padding="0px|0px|0px|||"][et_pb_column type="3_4" specialty_columns="3" _builder_version="3.25" custom_padding="|||" custom_padding__hover="|||"][et_pb_row_inner _builder_version="4.9.3" _module_preset="default" custom_margin="|||-44px|false|false" custom_margin_tablet="|||0px|false|false" custom_margin_phone="" custom_margin_last_edited="on|tablet" custom_padding="28px|||||"][et_pb_column_inner saved_specialty_column_type="3_4" _builder_version="4.9.3" _module_preset="default"][et_pb_text _builder_version="4.9.3" _module_preset="default" hover_enabled="0" sticky_enabled="0"]

QUESTION

Java using Eclipse IDE for Java developers    

 

 Assignment 2

Before attempting this project, be sure you have completed all of the reading assignments, non-graded exercises, discussions, and assignments to date.

Write a Java program which:

(1) Prompts a user to enter student two numbers and symbol for operation such as ‘+’, ‘-‘, ‘*’, and ‘/’ (use Scanner for input).

(2) Code uses nested if statement or switch to perform the operation on the two numbers

(3) If the provided symbol is valid, displays the input data along with the result of the calculation to the console. Otherwise displays error message

For example, for input: 7 8 + the calculation is addition and the result will be 15

Note 1: To read a single character by Scanner, you can read in as string and then use the first character. For example: scan.next().charAt(0)

Note 2: Be careful you do not have integer division

Note 3: If user inputs invalid symbol, print an error message only

Test program:

A minimum of 5 test cases (one for each valid operation and one for invalid operation) should be supplied in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. This table should contain 4 columns with appropriate labels and a row for each test case. An example template is shown below. Note that the actual output should be the actual results you receive when running your program and applying the input for the test record.

Make sure your Java program is using the recommended style such as:

 Javadoc comment up front with your name as author, date, and brief purpose of the program

 Comments for variables and blocks of code to describe major functionality

 Meaningful variable names and prompts

 Identifiers are written in upper CamelCase

 Class name starts with upper case letter and variables in lower case letter

 Constants are written in All Capitals

 Use proper spacing and empty lines to make code human readable

 

Capture execution:

You should capture and label screen captures associated with compiling your code, and running each of your 4 test cases.

Here are a couple sample runs:

Enter two integer numbers separated by space: 7 6

Enter operation symbol (+, -, *, or /): +

Evaluation: 7 + 6 = 13.0

Enter two integer numbers separated by space: 5 6

Enter operation symbol (+, -, *, or /): (

Not valid operation symbol

Example test cases: Input

Expected Output

Actual Output

Pass?

number 1 = 7

number 2 = 6

operation = +

Enter two integer numbers separated by space: 7 6

Enter operation symbol (+, -, *, or /): +

Evaluation: 7 + 6 = 13.0

Enter two integer numbers separated by space: 7 6

Enter operation symbol (+, -, *, or /): +

Evaluation: 7 + 6 = 13.0

Yes

Test Case 2

Test Case 3

Test Case 4

Test Case 5

 

 

 

[/et_pb_text][et_pb_text _builder_version="4.9.3" _module_preset="default" width_tablet="" width_phone="100%" width_last_edited="on|phone" max_width="100%"]

 

Subject Computer Science Pages 3 Style APA
[/et_pb_text][/et_pb_column_inner][/et_pb_row_inner][et_pb_row_inner module_class="the_answer" _builder_version="4.9.3" _module_preset="default" custom_margin="|||-44px|false|false" custom_margin_tablet="|||0px|false|false" custom_margin_phone="" custom_margin_last_edited="on|tablet"][et_pb_column_inner saved_specialty_column_type="3_4" _builder_version="4.9.3" _module_preset="default"][et_pb_text _builder_version="4.9.3" _module_preset="default" width="100%" custom_margin="||||false|false" custom_margin_tablet="|0px|||false|false" custom_margin_phone="" custom_margin_last_edited="on|desktop"]

Answer

Assignment 2

Testing the program

Input

Expected output

Actual output

Pass?

number 1 = 11

number 2 = 10

operation = +

Enter two integer numbers separated by space: 11 10

Enter operation symbol (+, -, *, or /): +

Evaluation: 11 + 10 = 21

Enter two integer numbers separated by space:                11 10

Enter operation symbol (+, -, *, or /):      +

Evaluation:              11 + 10 = 21

Yes

number 1 = 15

number 2 = 3

operation = -

Enter two integer numbers separated by space: 15 3

Enter operation symbol (+, -, *, or /): -

Evaluation: 15 - 3 = 12

Enter two integer numbers separated by space:                15 3

Enter operation symbol (+, -, *, or /):      -

Evaluation:              15 - 3 = 12

Yes

number 1 = 7

number 2 = 6

operation = *

Enter two integer numbers separated by space: 7 6

Enter operation symbol (+, -, *, or /): +

Evaluation: 7 * 6 = 42

Enter two integer numbers separated by space:                7 6

Enter operation symbol (+, -, *, or /):      *

Evaluation:              7 * 6 = 42

Yes

number 1 = 17

number 2 = 5

operation = /

Enter two integer numbers separated by space: 17 5

Enter operation symbol (+, -, *, or /): /

Evaluation: 17 / 5 = 3.4

Enter two integer numbers separated by space:                17 5

Enter operation symbol (+, -, *, or /):      /

Evaluation:              17 / 5 = 3.4

Yes

number 1 = 12

number 2 = 9

operation = @

Enter two integer numbers separated by space: 7 6

Enter operation symbol (+, -, *, or /): @

Invalid input

Enter two integer numbers separated by space:                12 9

Enter operation symbol (+, -, *, or /):      @

Invalid Input

Yes

 

Figure 1test case1: addition

Figure 2test case 2: subtraction

Figure 3test case3: multiplication

 

 

Figure 4test case4: multiplication

 

 

 

 

 

 

 

 

 

 

 

 

 

 

References

[/et_pb_text][/et_pb_column_inner][/et_pb_row_inner][et_pb_row_inner _builder_version="4.9.3" _module_preset="default" custom_margin="|||-44px|false|false" custom_margin_tablet="|||0px|false|false" custom_margin_phone="" custom_margin_last_edited="on|desktop" custom_padding="60px||6px|||"][et_pb_column_inner saved_specialty_column_type="3_4" _builder_version="4.9.3" _module_preset="default"][et_pb_text _builder_version="4.9.3" _module_preset="default" min_height="34px" custom_margin="||4px|1px||"]

Related Samples

[/et_pb_text][et_pb_divider color="#E02B20" divider_weight="2px" _builder_version="4.9.3" _module_preset="default" width="10%" module_alignment="center" custom_margin="|||349px||"][/et_pb_divider][/et_pb_column_inner][/et_pb_row_inner][et_pb_row_inner use_custom_gutter="on" _builder_version="4.9.3" _module_preset="default" custom_margin="|||-44px||" custom_margin_tablet="|||0px|false|false" custom_margin_phone="" custom_margin_last_edited="on|tablet" custom_padding="13px||16px|0px|false|false"][et_pb_column_inner saved_specialty_column_type="3_4" _builder_version="4.9.3" _module_preset="default"][et_pb_blog fullwidth="off" post_type="project" posts_number="5" excerpt_length="26" show_more="on" show_pagination="off" _builder_version="4.9.3" _module_preset="default" header_font="|600|||||||" read_more_font="|600|||||||" read_more_text_color="#e02b20" width="100%" custom_padding="|||0px|false|false" border_radii="on|5px|5px|5px|5px" border_width_all="2px" box_shadow_style="preset1"][/et_pb_blog][/et_pb_column_inner][/et_pb_row_inner][/et_pb_column][et_pb_column type="1_4" _builder_version="3.25" custom_padding="|||" custom_padding__hover="|||"][et_pb_sidebar orientation="right" area="sidebar-1" _builder_version="4.9.3" _module_preset="default" custom_margin="|-3px||||"][/et_pb_sidebar][/et_pb_column][/et_pb_section]