Results 1 to 3 of 3
  1. #1
    theuser is offline Member
    Join Date
    Jul 2009
    Posts
    1
    Rep Power
    0

    Default Please Help with Homework

    Hello Everyone

    This is my first time doing this, but it just had to be done. I have a Java assignment that I need to turn in on Friday 31st. This is the last homework and my professor made it kinda difficult. I was hoping some could take a look at it.

    I don't know if this is allowed on this forum. If not then i am very sorry for this, but if it is then please help me

    This is the homework

    Directions
    The files must be called <YourNameProg8.java> (driver program), Elevator.java (elevator file)Example: OliverLoveProg8.java (driver program)
    Elevator.java is required for the elevator file
    Ensure you include ALL files required to make your program compile and run.
    I would like to see your .java files only.
    Proper coding conventions required the first letter of the class start with a capital letter and the first letter of each additional word start with a capital letter.

    Elevator Control
    Write a program that mimics 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.


    YourNameProg8.java

    Your driver class should call the Elevator class file and implements the requirements above. Refer to the sample output to see what the prompts and output should look like.Within your driver class, use a loop that continues until the user enters “q” for quit. See the sample session for details.As you implement your solution, you should find that the selectFloor and fireAlarm methods contain some repeated coding logic. To avoid unnecessary redundancies in your code, have those methods call an appropriate helper method.Use a switch statement to handle the different choices for user input. (S-select floor, F-fire alarm, Q-quit)


    Elevator.java
    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.


    Sample Session: (output is NOT to be centered)

    Welcome to Oliver's 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)uitEnter 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.


    Thank you all

  2. #2
    DaFlake is offline Member
    Join Date
    Jul 2009
    Posts
    11
    Rep Power
    0

    Default

    This would actually be a fun little snippet to write. First, you need to break it down and just make the elevator go up and down. Then you can omit the 13th floor and add the rest. It look overwhelming at first, but if you break it into smaller chunks, you will be better able to manage the project.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Agrees with DaFlake: break the big problem down into little problems and then try to solve each little problem one at a time. Please feel free to come back if you have difficulties with your code and more specific questions. Best of luck.

Similar Threads

  1. help with homework
    By pinkdiamondgail in forum Advanced Java
    Replies: 7
    Last Post: 04-07-2009, 01:34 AM
  2. Java homework please
    By Indulgence in forum New To Java
    Replies: 1
    Last Post: 11-03-2008, 02:48 AM
  3. LF: Homework help with Java
    By excurssion in forum New To Java
    Replies: 2
    Last Post: 10-17-2008, 06:00 AM
  4. Homework help...
    By robrobrob in forum New To Java
    Replies: 4
    Last Post: 10-17-2008, 04:24 AM
  5. Need help with homework.
    By JavaNewbie0000 in forum New To Java
    Replies: 2
    Last Post: 07-31-2008, 03:06 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •