Preview only show first 10 pages with watermark. For full document please download

Java Exercise 1 (1)

Java Exercise 1 (1)

   EMBED


Share

Transcript

  1.   Fancy Name Printer  Requires: Basic printing capability Write a program that will print your Name in standard output in letters that are nine lines tall. Each big letter should be made up of a bunch of *'s. For example, if your name is DJE , then the output would look something like: ****** ************* ********** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ******** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ***** **** ********** 2.   Greeting Lucy  Requires: Variables, Strings. Write a program that asks the user's name, and then greets the user by name. Before outputting the user's name, convert it to upper case letters. For example, if the user's name is Lucy, then the program should respond Hello, LUCY, nice to meet you! 3.   Change Counter for Bank Cashers  Requires: Variables, numerical operators Write a program that helps the user count his change. The  program should ask how many 100 birr notes the user has then how many 50 birr notes, then how many 10 birr notes, then how many 5 birr notes, then how many 1 birr notes, then how many 50 cents, then how many 25 cents, then how many 10 cents,  then how many 5 cents. Then the program should tell the user how much money he has, expressed in birr. 4.   The egg counter  Requires: Variables, numerical operators. If you have N eggs, then you have N/12 dozen eggs, with N%12 eggs left over. (This is essentially the definition of the / and % operators for integers.) Write a program that asks the user how many eggs she has and then tells the user how many dozen eggs she has and how many extra eggs are left over. a.   A gross of eggs is equal to 144 eggs. Extend your  program so that it will tell the user how many gross, how many dozen, and how many left over eggs she has. For example, if the user says that she has 1342 eggs, then your program would respond with Your number of eggs is 9 gross, 3 dozen, and 10 since 1342 is equal to 9*144 + 3*12 + 10. 5.   Grading Program    Requires:  variables, data types, and numerical operators  basic input/output logic (if statements, switch statements) Write a program that allows the user to enter the grade scored in a java class (0-100). If the user scored a 100 then notify the user that they got a  perfect score. It should also print the student grade based on the  following scales 0-59 F 60-69 D 70-79 C 80-89 B 90-100 A a.   It should print an error “nun numeric value not allowed” if the user enters a character    b.   It should print an error “A student grade cannot be  Negative” if the user enters a negative value.  c.   It should print an error “A student grade cannot exceed maximum” i f the grade is greater than 100 6.   Cola Machine  Requires:  variables, data types, and numerical operators  basic input/output logic (if statements, switch statements) Write a program that presents the user w/ a choice of your 5 favorite beverages (Coke, Water, Sprite, Ambo water, Pepsi). Then to allow the user choose a beverage by entering a number 1-5. Output which beverage they chose. a.   Write the program using switch statement  b.   rite the program using if, else condition 7.   Bracketing Search    Requires:  variables, data types, and numerical operators  basic input/output logic (if statements, switch statements) loops (for, while, do-while)  psudo random numbers Write a program that calculates a random number 1 through 100. The program then asks the user guesses too high or too low then the program should output too high or too low accordingly. The program the user to guess the number.  If must let the user continue to guess until the user correctly guesses the number. a.   Modify the program to output how many guesses it took the user to correctly guess the right number. 8.   Bracketing Search 2    Requires:  variables, data types, and numerical operators  basic input/output logic (if statements, switch statements) loops (for, while, do-while)  pseudo random numbers In the above exercise modify the program so that instead of the user guessing a number the computer came up with, the computer guesses the number that the user has secretly decided. The user must tell the computer whether it guessed too high or too low. a.   Modify the program so that no matter what number the user thinks of (1-100) the computer can guess it in 7 or less guesses. 9.   Tic Tac Toe  Requires:  variables, data types, and numerical operators  basic input/output logic (if statements, switch statements) loops (for, while, do-while) arrays Make a two player tic tac toe game ( http://en.wikipedia.org/wiki/Tic-tac-toe ).