Homework
5A
Write a program called TetrahedronPrinter that will compute the surface area and the volume of a regular tetrahedron. A regular tetrahedron has 4 faces and all the edges are the same length. The formaulas and a picture are here. (Scroll down to find the formulas)
Ask the user to input the edge length using Scanner class. (Don't forget the prompt. Use "Enter the edge length: ") Test that the input is non-negative. If it is negative, print the message "Edge can not be negative".Otherwise, calculate and print both surface area and volume formatted to 2 decimal places. Use printf. Do not round with some other method.
For the draft, ask the user for the edge length and print it formatted to two decimal places with printf.
5A draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011218201643632731747962379
5A final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011218201643632731747962379&level=2
5B
E4.13.
Write a class called MyNumber. MyNumber has a constructor that takes an integer and a formatWithCommas method that returns a string with the number in the comma format. If the number is greater than 999,999 or less than 1000, formatWithCommas() method should return a string that says "Invalid length"
This class could contain other methods to manipulate the number, but for now we will only have this one method.
For the draft, provide a constructor that initializes the instance variable(s). Provide a stub for formatWithCommas so that the tester will compile with your class.
5B draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011218251160635860102472001
5B final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=13011218251160635860102472001&level=2
5C
Write a program that reads an integer and prints how many digits the number has, by checking whether the number is ≤ 10, ≤ 100, and so on. (Assume that all integers are less than one million.) Do not use String length method. If the number is negative, first multiply it with –1. If the number is greater than or equal to 1,000,000, print the message : "Too big"
Call the program DigitCountPrinter.java
Use Scanner. The prompt must be "Enter a number less than 1000000" Otherwise netbrat won't like it.
For the draft, read the number with Scanner and print the number if it is positive or -1 times the number if it is negative.
You should test thoroughly. Test the boundary conditions.
5C draft: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=1301131654293098829308860170
5C final: http://cs12.cs.sjsu.edu:8080/netbrat/files?repo=ext&problem=1301131654293098829308860170&level=2