This lab will help you to practice working with classes and objects. All parts of this lab must be part of a single java program – do not turn in more than one .zip file.
Problem 1 should be done in the file Lab11.java.
Problem 2 should be done in the files Lab11Problem2Driver.java and Lab11Problem2.java should be done in the file Lab11.java.
Problem 3 and 4 should be done in the file Lab11.java (instantiate objects and method calls), Calculator.java (problem 3) and you will need to create another class called StringCalculator.java for problem 4.
thisparameterclass.Instead,names andprovidetypes)thisforinformationtheclass’s methods.inacommentYou doblock.not need to implement
Question 1 will be graded with this rubric:
ClassClass fieldsfields haveareappropriateappropriateanddatacomprehensive:types:1point 1 point
ClassClass methodsmethods haveareappropriateappropriateandreturncomprehensive:typesandarguments:1point 1 point
2. Fix all of the errors and warnings in the class Lab11Problem2.java and associated driver program Lab11Problem2Driver.java.
You will receive one point for each error that you fix, up to a maximum of 5. You must fix the errors using good coding style.
Write a program that creates an instance of the Calculator class and allows a user to add, subtract, multiply and divide. The program should create an output file with
all of the operations the user has done during that execution. An example run of the program might look like this:
Total: 0.0
What do you want to do? + 25.5
Total: 25.5
What do you want to do? * 2
Total: 51.0
What do you want to do? – 31.0
Total: 20.0
TheWatassociateddoyouwantoutputto filedo?wouldqit then look like this:
0.0
+ 25.5
25.5
* 2
51.0
- 31.0
20.0
Question 3 will be graded according to this rubric:
ProgramProgram keepsinteractsthewithcorrectthe total:user as1 pointshown in the example: 1 point
Program instantiates a Calculator object and uses its fields and methods
Executionappropriately:continues1pointuntil the user types quit: 1 point
4. Make a new version of the Calculator class called StringCalculator that stores the
workfield with theasaprogramstringratheryouwrotethanasfora Questiondouble.The3withStringCalculatornomodificationclassothershouldthan instantiatingtotal a StringCalculator rather than a Calculator.
QuestionStringCalculator4willbegradedstoresaccordingthetotalto thisasa rubric:string and not as a double: 1 point
ATheCalculatortotalisupdateobject appropriatelycanreplacedbybyaeachStringCalculatormethodinthewithoutclass:1makingpoint any
other changes to a program: 1 point
Follows style guidelines and commented as appropriate: 1 point