Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Test case: ##################################### (javac *.java) || exit 1 maxTestCases=4 for currTestCase in `seq 1 $maxTestCases` #Loops through all test Cases do cp localTests/Test$currTestCase.java . javac

image text in transcribedimage text in transcribedimage text in transcribed

Test case:

#####################################

(javac *.java) || exit 1

maxTestCases=4

for currTestCase in `seq 1 $maxTestCases` #Loops through all test Cases do cp localTests/Test$currTestCase.java . javac Test$currTestCase.java

java Test$currTestCase > out.test # Runs Test Case

cat localTests/expectedOutput/Test${currTestCase}ExpectedOutput > outSol.test #Extracts Expected Output echo ====================Test$currTestCase====================

read -r line

cat outSol.test | tr A-Z a-z | tr -d ' ' > SolutionClean.test sed "s/^[ \t]*//" -i SolutionClean.test sed '/^[[:space:]]*$/d' -i SolutionClean.test

cat out.test | tr A-Z a-z | tr -d ' ' > SubmissionClean.test sed "s/^[ \t]*//" -i SubmissionClean.test sed "s/[ \t]*$//" -i SubmissionClean.test sed '/^[[:space:]]*$/d' -i SubmissionClean.test

cat outSol.test > testOut$currTestCase.test

git diff --word-diff=plain --word-diff-regex=[^[:space:]] -U0 SolutionClean.test SubmissionClean.test > diff.out if [ $? -lt 1 ] then printf " Test$currTestCase>>>Passed " else fail=`expr $fail + 1` printf " Test$currTestCase>>>Failed "

cat out.test | tr A-Z a-z > outClean.test cat outSol.test | tr A-Z a-z > outSolClean.test git diff --word-diff=plain --word-diff-regex=[^[:space:]] -U0 outSolClean.test outClean.test fi done

rm -f out.txt rm -f *.class *.test *.out Test*.java

Task: To save yourself the time it takes to solve basic math problems, you've decided to write a program to perform simple calculations. This class will need to utilize eleven methods to encapsulate all the required functionality. You are required to implement: Calculator.java Calculator Class Fields Name Type Access Modifier Description prevResult double private Stores the result of the most recent calculation count int private Stores the number of calculations Constructor Parameters Modifier(s) public None Methods Name Return Type Parameters Description add int int a, int b Return the result of adding a to b. subtract int int a, int b Return the result of subtracting b from a. multiply int int a, int b Return the result of multiplying a by b. divide double int a, int b Return the result of dividing a by b. Note: this method should do floating point division, not integer division. calculateCircleArea double intr Return the result of calculating the area of a circle with radius r. calculate Power int int a, int x Return the result of raising a to the power of x. getPrevResult double None Getter for prevResult. getPrevResult double None Getter for prevResult. getCount int None Getter for count. setPrevResult void double result Setter for prevResult. setCount void int count Setter for count. updateCount void None increments count by one. Hint: You may want to look into the Math class

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions