if
, and if/else
double
).
Sample Test Run
Weighted averages are typically expressed by specifying the percentage that each element contributes to the average. The percentages must sum to 100% for the average to be correct. To calculate the average, each element is multiplied by it's percentage (don't forget, 50% is actually .50), and the products then summed producing the average.
Write a program that prompts the user for a project, midterm and final and displays their weighted average (as a floating point,
i.e., double
) according to the following table:
Project | 20% |
Midterm | 30% |
Final | 50% |
Sample Test Run
Write a program that input an employee's last name, first name, and age, and if the employee is 65 or older, displays the employee's name together with the words "must retire" on the screen (nothing should be displayed if the employee is below the retirement age).
Here is a good opportunity to prctice your copy/paste (or duplicate source file) skills. Feel free to use your original payroll
program's (Lab 1.3/1.4) source as a starting point (it has some of the code you will be using-- the boilerplate of course, some of the declarations,
the code to read in the last and first name, possibly the for
loop,...)
Sample Test Run #1
Sample Test Run #2
Now that the company has reduced it workforce and dramatically cut expenses, BONUSES can be given to the top-level executives (departments 1 and 2)! But given the public's anger at outrageous payouts to executives, management has decided to give EVERYONE a bonus: executives get cash, while the rest of the company get a cute little teddy bear with the comany name on its belly.
Write a program that reads in (from the keyboard) an employee's last name, first name, and department number, and displays the employee's name and the bounus they shoud receive: either the string "$$$!!!" or the string "Cute little Teddy Bear"
Sample Test Run #1
Sample Test Run #2