Mn404 - fundamentals of operating systems and java


Assignment: Write an Algorithm/ flowchart and then convert it to a java program for given specifications/ requirements.

Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements in them.

a. Apply principles of abstraction and problem solving in an object-oriented programming language
b. Apply knowledge of programming constructs in developing computer programs
c. Create programs based on incremental development processes of designing, coding, testing and debugging.

Assignment Specification

Task 1

Write an algorithm and a program that mimic the operations of the inside of an elevator. More specifically, the program simulates what happens when the user chooses to go to a particular floor, and it simulates what happens when the user pulls the elevator's fire alarm. Assume the elevator is in a high-rise building that has floors numbered 1 through 100.

Within your Elevator class, include these methods:

- SelectFloor - This method prompts the user for a floor selection and then performs input validation for the floor selection. If the floor selection is inappropriate (less than 1, greater than 100), then the method prints an error message. If the floor selection is OK, the method simulates going to that floor. See the sample session below for the format of the simulation message.

- FireAlarm- This method prints a "danger" message and then simulates going to the first floor. Note that I'm assuming this is a high tech fire alarm that is programmed to force the elevator to go to the first floor! See the sample session below for the format of the "danger" message.

Within your ElevatorDriver class, use a loop that continues until the user enters "q" for quit.

Task 2

Write an algorithm and a program that plays the ancient Chinese game of NIM. Actually, this is a simplified version of the game. Each game starts with a user-specified number of stones in a pile. The user and the computer take turns removing either one or two stones from the pile. The player who takes the last stone loses. Your program should have the computer use the optimal playing strategy. The optimal strategy is as follows:

Divide the remaining number of stones by three. If the remainder is zero, then two stones are removed, or else one stone is removed. For example, if the remaining number of stones is nine or fifteen, then two stones are removed; if the remaining number of stones is eight or ten, then one stone is removed.

a) Your program should allow the user to play additional games of NIM as long as he/she enters a "y" or "yes" (lowercase or uppercase) in response to a "Do you want to play again?" prompt.

b) Add input validation to your Nim program. More specifically, (1) ask the user to re-enter the number of starting stones if he/she doesn't enter a positive number, and (2) ask the user to re-enter the number of stones to be removed if he/she doesn't enter an appropriate number.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Mn404 - fundamentals of operating systems and java
Reference No:- TGS02628347

Expected delivery within 24 Hours