Description
Notes:
i. Each task should be presented during the lab, demo worth 70% of the workshop marks and code uploading worth the other 30%. ii. All the tasks should be demoed in Jan 17th lab.
iii. Make sure you have all security and check measures in place, such as wrong data types etc., no need to implement Exception as we haven’t covered yet. There are other ways to handle bad input data.
iv. Given output structure is just for student to have a glimpse what the output can look, students are free to make the output better in any way.
Other inputs can be given during demo, so make sure you test your program properly.
Task1. Zeller’s congruence is an algorithm developed by Christian Zeller to calculate the day of the week. The formula is
where
· q is the day of the month.
· j is the century (i.e., 𝑦𝑒𝑎𝑟100)
· k is the year of the century (i.e., year % 100).
Note that the division in the formula performs an integer division.
Write a program that prompts the user to enter a year, month, and day of the month, and displays the name of the day of the week. Here are some sample runs:
Task2. The monthly payment for a given loan pays the principal and the interest. The monthly interest is computed by multiplying the monthly interest rate and the balance (the remaining principal). The principal paid for the month is therefore the monthly payment minus the monthly interest.
Write a program that lets the user enter the loan amount, number of years, and interest rate and displays the amortization schedule for the loan. Here is a sample run:
System.out.println(i + ” ” + interest
+ ” ” + principal + ” ” + balance);
}
Task3. Write a program that plays the popular scissor–rock– paper game. (A scissor can cut a paper, a rock can knock a scissor, and a paper can wrap a rock.) The program randomly generates a number 0, 1, or 2 representing scissor, rock, and paper. The program prompts the user to enter a number 0, 1, or 2 and displays a message indicating whether the user or the computer wins, loses, or draws. Here are sample runs: (Hint: Use switch statement)
Reviews
There are no reviews yet.