| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
|
Triangle *:
Write a Java program that generates an isoscelestriangle made of asterisks. The program should prompt the user to specify thesize of the triangle. Make sure variablenames are appropriate, and make sure there are comments for the weird variableslike sideSize. Use good style.
Samplesession:
Enter the size of the equal sides in an isoscelestriangle: 6 * ** * * * * * * ****** BankBalance :
The First National Bank of
The bank doubles the customer’s balance everyyear until the customer’s balance reaches one million. The customer isn’t allowed to touch the money (nodeposits or withdrawals) until the customer’s balance reaches one million. If the customer dies before becoming amillionaire, the bank keeps the customer’s balance. Note: Customers close to $1,000,000 tend to get“accidentally” run over in the bank’s parking lot.
Writea program that prompts the user for a starting balance and then prints thenumber of years it takes to reach $100,000 and also the number of years ittakes to reach $1,000,000.
Sample session:
Enterstarting balance: 10000 Ittakes 4 years to reach $100,000. Ittakes 7 years to reach $1,000,000. **************************************************************************************************************** Economic Policy *:
The following rules illustrate traditional economic policy theory in terms of regulating a government’s economy.
a) If the annual growth rate is less than 1%: · If inflation is less than 3%, recommended economic policy is: Increase welfare spending, reduce personal taxes, and decrease discount rate. · Otherwise, recommended economic policy is: Reduce business taxes.
b) If the annual growth rate is greater than 4%: · If inflation is less than 1%, recommended economic policy is: Increase personal and business taxes, and decrease discount rate. · If inflation is greater than 3%, recommended economic policy is: Increase discount rate.
Write a program that applies these economic policy practices. More specifically, read in growthRate and inflation values and output the recommended economic policy for the given economic situation. If there is no recommended economic policy for the given economic situation, then output “No change in economic policy.”
One-Hundredth Birthday *:
Write a Java program that prompts the user for his/her birthday month, day, and year and prints the date of the user’s one-hundredth birthday. There are several different ways to calculate and print the one hundredth birthday year. One acceptable technique is to store the calculated one-hundredth birthday year in a variable before you print it.
Sample session:
Enter the month you were born: March Enter the day you were born: 18 Enter the year you were born: 1986 You will be 100 on
Loop Termination by User Query ─ Pseudocode *:
Write pseudocode for an algorithm that calculates and prints the overall MPG (miles per gallon) for a series of miles and gallons user inputs. Use a loop to repeatedly ask the user to enter a miles value and a gallons value. Within the loop, accumulate miles and gallons separately. The algorithm should generate a display of prompts, inputs, and final output that looks like this:
Sample session:
Do you want to calculate miles per gallon? (y/n): y Enter miles: 35 Enter gallons: 1 Do you want to continue? (y/n): y Enter miles: 36 Enter gallons: 1 Do you want to continue? (y/n): n Overall MPG = 35.5
Provide a graceful response if the total gallons equals zero. *****************************************************
Speed of Sound ─ Pseudocode *:
The following table provides the speed of sound waves in several materials:
Material Sound Velocity iron 5950 meters/sec polystyrene 2350 meters/sec water 1531 meters/sec air 331.5 + 0.6 x T meters/sec, where T is the temperature in degrees Celsius
Write pseudocode that uses this table to calculate the speed of sound in various materials. More specifically, read in a material value and output the speed of sound in that material. For air calculations, you’ll need to read in a second value – temperature in degrees Celsius. ******************************************************* Number of Stamps ─ Pseudocode *:
Whenever you mail a letter, you must decide how much postage to put on the envelope. You like to use this rule of thumb – use a stamp for every five sheets of paper or fraction thereof. For example, if you have 11 sheets of paper, then you use three stamps. Since you’re parsimonious, if an envelope requires more than three stamps, then you simply don’t mail the envelope. Show how the number of stamps per envelope would be calculated. Provide a solution in the form of pseudocode. Your pseudocode must read in appropriate data and print how many stamps to use.
********************************************************
Annual Bonus ─ Pseudocode *:
Assume a company pays an annual bonus to its employees. The bonus is based on the number of years the employee has been with the company. Employees working at the company for less than 5 years receive a bonus equal to 2% percent of their salary; all others receive a bonus equal to 1% of their salary. Write pseudocode which shows how an employee’s bonus is calculated. Include reading in appropriate data and printing an output message that mimics the format of the following message, where <bonus-value> represents the numeric value for the bonus:
Congratulations! Your bonus is $<bonus-value>.
Don’t forget the “$” and the closing period.
***************************************************************************************************************************
Chapter 1 Test
1. For each of the following devices, indicate whether it is input, output, or memory: a) CD-ROM _________ b) keyboard _________ c) monitor ________
2. Multiple Choice: If a memory device loses its data when power is off, we say it is: a) faulty b) ephemeral c) volatile d) non-permanent
3. An informal outline that describes what a program does is called ____________.
4. A computer program that converts Java source code to Java bytecode is called a __________.
5. The computer program that converts Java bytecode to machine code (or object code) is called the _____________________________.
6. What company developed the Java language?
7. What is the file extension for a bytecode file?
8. What is your teacher's name? |