Homework
3A
Write a BankAccountTester class whose main method does the following
Construct a BankAccount with the no-argument constructor. Deposit $351.50 and withdraw $40. Then print the balance. Also print the expected output.
Construct a BankAccount with an opening balance of $1000 (use the second constructor). Deposit $275 and withdraw $121.45. Print the balance and the expected output.
You will need to copy and paste the given BankAccount into your project ans then write the BankAccountTester class. This project will consist of two classes: BankAccount (given to you and unmodified by you) and BankAccountTester which you write.
For the draft, construct the first BankAccount. To keep NetBrat happy add these two lines
System.out.println("no output");
System.out.println("Expected: no output");
You will only submit BankAccountTester
3A draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13010722182487636812491266829
3A final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13010722182487636812491266829&level=2
3B
Create a class SodaCan that respresents a soda can. Comment the class, every public method every parameter and every return value with javadoc style comments
A SodaCan has a radius and height measured in inches. It also has a contents which is the number of fluid ounces left in the can.
Provide 2 constructors:
When a SodaCan is created, it is filled to capacity, that is, the contents is the volume of the can expressed in fluid ounces. To calculate the capacity in cubic inches, first calculate the volume of a cylinder of the given height and radius formula given here. For the PI value, use the constant Math.PI in the Math class. Then convert from cubic inches to fluid ounces using this formula (1 Cubic Inch = 0.554112554 Fluid Ounces). Be sure to set the value of contents in each constructor.
Povide these accessor methods:
Also provide these methods (the first is a mutator and the second is an accessor:
For the draft version, provide the three instance variables and the no-argument consturctor. Remember that instance variables should be private.
3B draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=1302112141914548090284324761
3B final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=1302112141914548090284324761&level=2
3C
Do problem E3.11. You will be supplied with the LetterPrinter class.
Note: you should be able to call getText() twice and get the same result.
For the draft, declare the instance variables and write the constructor. Provide stubs (empty methods) for the two methods so your class will compile with the tester. You will need to have a return statement in getText. Just return null. Also write the javadoc for the methods and constructor along with thei parameters and return values
3C draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13010819384073719181014174253
3C final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13010819384073719181014174253&level=2