Programming and Problem Solving with Java

(やまだぃちぅ) #1
679

9.Write the HTML statements that create the following title: Now is the time!
10.Write the HTML tag(s) to place a horizontal rule on the page.
11.What HTML symbols enclose a paragraph?

Programming Problems


1.Write an applet that calculates the factorial of a number using bytearithmetic.
That is, the input value is a byte, and the value returned by the factorial
function is a byte. Execute your applet by inputting increasing values beginning
with 0. What is the largest factorial value that can be calculated? What
happens when you enter a larger value?
2.Write an applet that calculates the factorial of a number using short
arithmetic. That is, the input value is a short, and the value returned by the fac-
torial function is a short. Execute your applet by inputting increasing values be-
ginning with 0. What is the largest factorial value that can be calculated? What
happens when you enter a larger value?
3.Write an applet that calculates the factorial of a number using longarithmetic.
That is, the input value is a long, and the value returned by the factorial
function is a long. Execute your applet by inputting increasing values beginning
with 15. What is the largest factorial value that can be calculated? What
happens when you enter a larger value?
4.Write an applet that calculates the factorial of a number using float
arithmetic. That is, the input value is a float, and the value returned by the fac-
torial function is a float. Execute your applet by inputting increasing values be-
ginning with 50. What is the largest factorial value that can be calculated?
What happens when you enter a larger value?
5.Write an applet that calculates the factorial of a number using double
arithmetic. That is, the input value is a double, and the value returned by the
factorial function is a double. Execute your applet by inputting increasing
values beginning with 100. What is the largest factorial value that can be calcu-
lated? What happens when you enter a larger value?
6.Write an applet that counts the number of comparisons required to sort a list
of integers using the selection sort algorithm. Have the user enter the size of
the list, and report back the number of comparisons. Run your applet five times
and record the size of the list and the number of comparisons required. Relate
your findings to the discussion of Big-O complexity in Chapter 11.
Free download pdf