Placeholder

CMIS 141 Assignment 2 Perform Operation on Two Numbers

$19.00

Description

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?
SCREENSHOTS
SOLUTION
PAYMENT
The solution consists of:
A report word document for this assignment
All Java programs in case you want to run theses programs on your computer.
Screenshots while running programs
Attachments [Move over files to preview content of those files]
CMIS_141_Assignment_2.zip (208.65 KB)
CMIS 141 Assignment 2 Report.docx
CMIS141-Assignment-2-Screenshot-1.png
CMIS141-Assignment-2-Screenshot-2.png
CMIS141-Assignment-2-Screenshot-3.png
Source Code
CMIS141Assignment2.java
Preview CMIS141Assignment2.java
xxx {
xxxxxx[] xxxxxx = xxxxx.xxxx().xxxxx(” “);
xxxxxxxx = xxxxxxx.xxxxxxxx(xxxxxx[0]);
xxxxxxxxx = xxxxxxx.xxxxxxxx(xxxxxx[1]);
} xxxxx (xxxxxxxxx xx) {
System.out.println(“Invalid input data.”); System.exit(0); } System.out.println(“Enter operation symbol (+,-,*, or /):”); input = sc.nextLine(); char operation = input.charAt(0); String validOperation = “+-*/”; if (!validOperation.contains(Character.toString(operation))) { System.out.println(“Not valid operation symbol”); System.exit(0); } if (operation == ‘+’) {
xxxxxx.xxx.xxxxxxx(“xxxxxxxxxx: ” + xxxxxx.xxxxxxx(xxxxxxxx) + ” ” + xxxxxxxxx + ” ” + xxxxxx.xxxxxxx(xxxxxxxxx) + ” = ” + xxxxxx.xxxxxxx(xxxxxxxx + xxxxxxxxx));
} xxxx xx (xxxxxxxxx == ‘-‘) {
xxxxxx.xxx.xxxxxxx(“xxxxxxxxxx: ” + xxxxxx.xxxxxxx(xxxxxxxx) + ” ” + xxxxxxxxx + ” ” + xxxxxx.xxxxxxx(xxxxxxxxx) + ” = ” + xxxxxx.xxxxxxx(xxxxxxxx – xxxxxxxxx));
} xxxx xx (xxxxxxxxx == ‘*’) {
xxxxxx.xxx.xxxxxxx(“xxxxxxxxxx: ” + xxxxxx.xxxxxxx(xxxxxxxx) + ” ” + xxxxxxxxx + ” ” + xxxxxx.xxxxxxx(xxxxxxxxx) + ” = ” + xxxxxx.xxxxxxx(xxxxxxxx * xxxxxxxxx));
} xxxx { // /
Price: $19
You May Also Like:
CMIS 141 Assignment 1 Student GPA
CMIS 141 Assignment 3 Calculate Student Grade
CMIS 141 Assignment 4 Output Triangle and Diamond Pattern
CMIS 141 Assignment 5 Body Mass Index
CMIS 141 Assignment 6 Highest and Lowest Score
CMIS 141 Final Project Employee Salary

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.