Program that mimic operations of the inside of an elevator

Assignment Help JAVA Programming
Reference no: EM131854464

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.

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

Assignment Specification

Task I

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. See the sample session for details.

Sample session:

Welcome to XXX's (students name and ID) elevator simulator!

Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>x
Invalid selection.
Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>F
Danger! You must exit the building now!
Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>s
Enter the floor that you'd like to go to ==>102
Invalid floor selection - must be between 1 and 100.
Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>s
Enter the floor that you'd like to go to ==>15
Going up..2..3..4..5..6..7..8..9..10..11..12..13..14..15..Ding!
Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>s
Enter the floor that you'd like to go to ==>10
Going down..14..13..12..11..10..Ding!
Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>f
Danger! You must exit the building now!
Going down..9..8..7..6..5..4..3..2..1..Ding!
Options: (s)elect a floor, (f)ire alarm, (q)uit
Enter s, f, or q ==>q

Optional extension:

Some hotels cater to superstitious people by omitting the 13th floor. Modify your program so that there is no 13th floor.

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. See the sample session for required wording.

Sample session:

T H E G A M E O F N I M

Enter number of starting stones: 7
Would you like to go first? (y/n): yEs
How many would you like to remove - 1 or 2? 1
The number of stones left is 6.
The computer removes 2 stones.
The number of stones left is 4.
How many would you like to remove - 1 or 2? 2
The number of stones left is 2.
The computer removes 1 stone.
The number of stones left is 1.
How many would you like to remove - 1 or 2? 1
The number of stones left is 0.
The computer wins!
Do you want to play again? (y/n): Y

Enter the number of starting stones: 4
Would you like to go first? (y/n): n
The computer removes 1 stone.
The number of stones left is 3.
How many would you like to remove - 1 or 2? 2
The number of stones left is 1.
The computer removes 1 stone.
The number of stones left is 0.
You win!
Do you want to play again? (y/n): n

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.

Sample session:

T H E G A M E O F N I M

Enter the number of starting stones: 7
Would you like to go first? (y/n): yEs
How many would you like to remove - 1 or 2? 1
The number of stones left is 6.
The computer removes 2 stones.
The number of stones left is 4.
How many would you like to remove - 1 or 2? 2
The number of stones left is 2.
The computer removes 1 stone.
The number of stones left is 1.
How many would you like to remove - 1 or 2? 2
You cannot remove 2 stones.
How many would you like to remove - 1 or 2? 1
The number of stones left is 0.
The computer wins!
Do you want to play again? (y/n): Y

Enter the number of starting stones: 0
You cannot start with 0 stones.
Enter the number of starting stones: 4
Would you like to go first? (y/n): n
The computer removes 1 stone.
The number of stones left is 3.
How many would you like to remove - 1 or 2? 0
You cannot remove 0 stones.
How many would you like to remove - 1 or 2? 3
You cannot remove 3 stones.
How many would you like to remove - 1 or 2? 2
The number of stones left is 1.
The computer removes 1 stone.
The number of stones left is 0.
You win!
Do you want to play again? (y/n): n

Reference no: EM131854464

Questions Cloud

Describe the balance of forces that hold together : Question:1. a) Describe the balance of forces that hold together the subatomic particles in the nuclei of atoms.
Discuss news stories and the hr implications arising : HRMT20024 discussed news stories and the HR implications arising from these stories - write about one of the three news stories on Moodle
What is the coupon rate on the bonds : Maxcorp’s bonds sell for $1,129.03. The bond life is 9 years, and the yield to maturity is 8.4%. What is the coupon rate on the bonds?
Electromagnetic waves travel through space with a speed : The frequency of microwaves with a wavelength of 3.0cm is how many hertz?
Program that mimic operations of the inside of an elevator : Unit Title Fundamentals of Operating Systems and Java Programming - Write an algorithm and a program that mimic the operations of the inside of an elevator
What is firms tax expense in its latest financial statements : HI5020 Corporate Accounting - What is your firms tax expense in its latest financial statements and Why is the income tax payable not the same as income
Align all of your lesson plans with content standards : Align all of your lesson plans with content standards. Content standards are the roadmap for student earning and are the foundation
Develop presentation skills in the professional environment : Develop a PowerPoint presentation (12-18 slides in length). It should include a title slide, an agenda slide, body content slides, a closing slide.
Write a theoretical perspective section : Based on your research interest, corporate culture, write a Theoretical Perspective section for your envisioned dissertation research.

Reviews

len1854464

2/8/2018 3:22:08 AM

Task - 2 Excellent Algorithm devised (logic used) taking into considerations all possible end conditions. Flawless Code implemented Relevant Algorithm devised (logic used) taking into considerations all possible end conditions. Flawless Code implemented Generally relevant Algorithm devised (logic used) taking into considerations most of the end conditions. Flawless Code implemented. Some relevance in the algorithm and few conditions are considered. The logic used is not relevant. Demonstration Logic is clear and easy to follow with strong arguments Consistency logical and convincing Mostly consistent logical and convincing Adequate cohesion and conviction Argument is confused and disjointed

len1854464

2/8/2018 3:22:00 AM

Demonstration Tutor will see the outputs and also assess your understanding of work done for this assignment in the laboratory class. This will be done in Week-12 laboratory class . 10 Total 50 Grades Excellent Very Good Good Satisfactory Unsatisfactory Task - 1 Excellent Algorithm devised (logic used) taking into considerations all possible end conditions. Flawless Code implemented Relevant Algorithm devised (logic used) taking into considerations all possible end conditions. Flawless Code implemented Generally relevant Algorithm devised (logic used) taking into considerations most of the end conditions. Flawless Code implemented. Some relevance in the algorithm and few conditions are considered. The logic used is not relevant.

len1854464

2/8/2018 3:21:52 AM

Marking criteria: Section to be included in the report Description of the section Marks Task 1 Algorithm Complete error-free program 10 10 Task 2 Algorithm Complete error-free program 10 10 Following points to be considered: • Include import statement • Include a comment at the beginning of your program with basic information and a description of the program • Your code should be properly indented • Give meaningful names to variables and classes in your code. • Correct use of programming structures • Your program compiles successfully without any errors • Your program is interactive and gives correct output. • Provide snapshot of the Sample output along with the source code.

len1854464

2/8/2018 3:21:44 AM

Submission Guidelines • All work must be submitted on Moodle by the due date along with a completed Assignment Cover Page. • The assignment must be in MS Word format, 1.5 spacing, 11-pt Calibri (Body) font and 2 cm margins on all four sides of your page with appropriate section headings. • Reference sources must be cited in the text of the report, and listed appropriately at the end in a reference list using IEEE referencing style.

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd