Section 1 – Console Applications
1) Write a program that uses two nested for loops and the modulus operator (%) to
detect and print prime numbers. A prime numbers are integral numbers that are
not evenly divisible by any other numbers except themselves and 1. Use your
program to print all the prime numbers from 0 to 100,000. Print 10 numbers per
output line, separated by two spaces.
2) Write a method that creates and initializes a two-dimensional array of primitive
type double. The size of the array is determined by the arguments of the method,
and the initialization values are a range determined by beginning and ending
values that are also arguments of the method (so four arguments total). Create a
second method that will print the array generated by the first method. In main(),
test the methods by creating and printing several different sizes of arrays.
3) Write an application that prints the following diamond shape. You may use output
statements that print a single asterisk (*), a single space or a single newline
character. Maximize your use of repetition (with nested for statements), and
minimize the number of output statements.
Section 2 – GUI Applications
4) Create the following GUI and provide full functionality for the calculator.
5) Write a temperature conversion application that converts from Fahrenheit to
Celsius. The Fahrenheit temperature should be entered from the keyboard (via a
JTextField). A JLabel should be used to display the converted temperature. Use the
following formula for the conversion:
Celciu s = 5
× (Far en h eit – 32)

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

New Download