Practice Mid term exam

#1 Create an applet that allows the user to enter a number and display the number is an even number or an odd number on a label control.
 

#2 Create an applet that allows the user to enter an input number as minutes. The program will change the convert 60 minutes to an hour . For example : 256 minutes will be 4 hours 16 minutes.
 

#3. Create an applet that display a lunch menu of 5 selects. The applet will display the price of the menu depends on the user's input number.
 

#4. Create a dog class. The dog class's data includes name, age, and color. Create a UseDog class which instatiates and displays 3 dogs.


 

#5. Corret the errors of prac1.java.


 

#6. Correct the errors of prac2.java.

Mid term exam

1. Write a Java application that prompts the user to enter a string from an inputbox. Then the application counts the total number of letters contained in the string.

2. Create a Java application containing an array that stores 5 prices. The 5 prices are { 3.99, 10.50,2.25, 9.45,12.55}. The applicaction should
a) display the sum of all the prices.
b) calculate the average of the prices.

3. Write a Java application that displays a menu of 5 items in a McDonald resturant as following:
 
Double Cheese 3.99
Big Mac 5.15
McChicken 5.95
McRid 5.45
McFish 6.25
Prompt the user to choose an item using the number (1,2,3,4 or 5) that corresponds to the item from an input box. The user enters a "0" to quit the application. After the user makes the selection, the program displays the menu and and cost of the item.

4. Write an Java application that displays the result of a series of 10 die tosses. Use the Math.random() function you first learned about in Chapter 4 to generate a number between 1 and 6; You will use a statement similar to:
result =Math.random();

Use the following statements to help you.
Random generator = new Random();
This statement allows you to create a Random object.
int throw = generator.nextInt(10) + 1;
This statement allows you to create a random number between 1 to 10 .
 


 

#1 Download Mid1.java, debug the program.
 

#2 Download Mid2.java, debug the program.
 

#3 Create an applet that simulates a die game. The program rolls a die, displas the result and the winning money from the result. The rules for the game are below.
 

1 or 2 thank you for playing, No money
3 or 4 $1.00
5 or 6 $2.00

#4 Create a class named Hamburger. Data fields include a string for size (large, medium, samll), and a double type for price. Include two constructor methods. One constructor assigns the default values and another takes the input from the user.
 

Create a "testHamburger" program that instantiates 3 objects and displays the size and price of the objects.


Save these two files as Hamburger.java and testHamberger.java.
 

#5 Create an applet that takes a number of pennies as an input from users. Your program will convert the pennies to proper money. For example , 598 pennies will be 5 dollars, 3 quarters, 2 dimes, 0 nickles, and 3 pennies. The output will be displayed on a label control.
Save this file as Mid5.java.
 

#6 Create an applet that reads two input numbers - working hours, and hourly rate. The applet will calcuate the salary by multipy the working hours to hourly rate. The salary will be displayed on a label control.
Save the file as Mid6.java.
 

You must submit the following files:
mid1.class
mid2.class
mid3.class
Hamburger.class & testhamburger.class
mid5.class
mid6.class
midTermCode.doc
 

Final exam review

You can use an applete or a general window program for the following questions.
 

#1 Use polygon statemet to draw your boat.
 

#2. Draw a red basketball.
 

#3. Create an applet that show a ball with alternate colors - red and yellow. If you click the button, the applet will alternate the colors.
 

#4. Create an applet that alternate 4 colors for a shirt.
 

#5. Create an applet that displays the elements of an array and the sum of the array.
 

#6. Create an applete that displays the price of a meal. Store the price in a price array. When the user enters the meal selection, the applet will display the price.
 

#7. Create an applet that displays the capital of 5 states. You need to use two arrays. The state array includes CA,TX,NM,OR,NV. and the capital array includes the capitals of these five states. The applet dislays the correct capital for the array.
 

#8 Create an applet that simulates the quick pick machine and displays the 6 lucky number.
 

#9 Create a class name "Movie" that contains data fields for title and director. Next create a subclass named Action, and additional method to get and set the Rate level field. Write a program that demonstrates using objects of each class.

 

#10 Create an applet that shows the capital of the states. Put at least three states in a list box. If the user click on "California", the capital label box shows "Sacromento"..etc.

 

#11 Create an applet that shows a picture. Download the dolphine picture file to your computer.
 

Final exam

#1 Use polygon statemet to draw your boat.
 

#2. Draw a red basketball.
 

#3. Create an applet that show a ball with alternate colors - red and yellow. If you click the button, the applet will alternate the colors.
 

#4. Create an applet that alternate 4 colors for a shirt.
 

#5. Create an applet that displays the elements of an array and the sum of the array.
 

#6. Create an applete that displays the price of a meal. Store the price in a price array. When the user enters the meal selection, the applet will display the price.
 

#7. Create an applet that displays the capital of 5 states. You need to use two arrays. The state array includes CA,TX,NM,OR,NV. and the capital array includes the capitals of these five states. The applet dislays the correct capital for the array.
 

#8 Create an applet that simulates the quick pick machine and displays the 6 lucky number.
 

#9 Create a class name "Movie" that contains data fields for title and director. Next create a subclass named Action, and additional method to get and set the Rate level field. Write a program that demonstrates using objects of each class.

 

#10 Create an applet that shows the capital of the states. Put at least three states in a list box. If the user click on "California", the capital label box shows "Sacromento"..etc.

 

#11 Create an applet that shows a picture. Download the dolphine picture file to your computer.

 

#12. Create a calculateGui program that prompts the user to enter two double numbers. The calculateGui has four buttons - add, sub, multiply and divide . When the user clicks on the add button, the application displays the sum of these two numbers on a label box, when the user clicks on the sub button, the application displays the difference of these two numbers on a lable box. The caluclateGui will call calculate class to perform the calculation.

 


#13. Create a time card appliation that allows the user to enter two different times in a day and calcuate the difference of the two times. The first time must prior to the second time. (use military time).
The timeGui application includes 6 text boxes to allow the user to enter the hours, minutes, and seconds. The timeGui class calls time class to calulate the difference of the two different times