Suppose we attend a party. To be sociable, when we arrive, we will shake hands with
everyone who is already at the party. Write a program that prompts the user for the
total number of guests at the party. Using the for statement
, your
program will compute, and display, the number of handshakes that occur as each guest
arrives. Your program should also compute and display the total number of handshakes
that occur after all guests have arrived.(Hint Upon arrival, each person shakes
hands with everyone that is already there. You can assume that there is only one host
for the party). Example:
How many guests are invited to the party: 5 When Guest 1 arrives, Handshakes=1, Total Handshakes=1 When Guest 2 arrives, Handshakes=2, Total Handshakes=3 When Guest 3 arrives, Handshakes=3, Total Handshakes=6 When Guest 4 arrives, Handshakes=4, Total Handshakes=10 When Guest 5 arrives, Handshakes=5, Total Handshakes=15
Name this program HandShakes
(Exercises #10, Page 249) Write a program that will compute stastics for eight coin tosses. The user will enter either an h for heads or a t for tails for the eight tosses. The program will then display to total number and percentages of heads and tails. Use the increment operator to count each h or t that is entered. For example, a possible sample dialogue between the program and the user might be:
For each coin toss enter either h for heads or t for tails. First toss: h Second toss: t Third toss: t Fourth toss: h Fifth toss: t Sixth toss: h Seventh toss: t Eighth toss: t Number of heads: 3 Number of tails: 5 Percent heads: 37.5 Percent tails: 62.5
Hint: You can use the switch statement
to generate the desired output.
Name this program CoinTosses
Write a program that prompts the user for a beginning bank balance and an interest rate. The program will display the value of the account at the end of each year for 10 years. The output should show the value of the account for three different methods of compounding interest:
Your program should allow the user to perform the calculation multiple times for different starting balances. A negative starting balance indicates that the user is done.
Name this program BankInterest
For all the following words, if you move the first letter to the end of the word, and then spell the word the result backwards, you will get the original word:
banana dresser grammar potato revive uneven assess
Write a program that reads a word at a time and determines whether it has this property. Continue reading and testing words until you encounter the word quit. Treat upper case letters as lowercase letters.
Name this program CheckWords
Please submit the completed assignment on Blackboard by attaching all your .java files. Make sure to attach all your programs to each submission.