Ask a question from expert

Ask now

Document Related to JAVA Programming

15 Pages1971 Words338 Views
   

Added on  2020-05-16

Document Related to JAVA Programming

   Added on 2020-05-16

BookmarkShareRelated Documents
Running head: JAVA PROGRAMMINGJAVA ProgrammingName of the student:Name of the University:Author note:
Document Related to JAVA Programming_1
1JAVA PROGRAMMINGTable of ContentsTASK-1 (Elevator System)........................................................................................................2Algorithm...............................................................................................................................2Source Code...........................................................................................................................3Output.....................................................................................................................................6TASK-2 (Game of NIM)............................................................................................................8Algorithm...............................................................................................................................8Source code............................................................................................................................9Output...................................................................................................................................12
Document Related to JAVA Programming_2
2JAVA PROGRAMMINGTASK-1 (Elevator System)AlgorithmSTARTStep 1.Declare function main().Step 2.Display menu and take user input for choice.Step 3.Convert character input into uppercase.Step 4.In Case user choses ‘S’ goto next step else goto step 7.Step 5.Call function SelectFloor().Step 6.If function returns 1 call function Movement(), else goto step 2.Step 7.In Case user enters ‘F’, call function FireAlarm() and then goto step 2.Step 8.In Case user enters ‘Q’, display Exit message and goto step 10.Step 9.If user enters wrong choice, display error message and goto step 2.Step 10.End of function main().Function SelectFloor()Step 1.Take user input of floors he wishes to travel in variable temp.Step 2.If tempInput <1 or tempInput>100, display error message. goto step 1.Step 3.If tempInput = currentFloor value, display “same floor error” message andreturn 0 to calling function, else next step.Step 4.Set floors to tempInput and return 1 to calling function.Step 5.End of function SelectFloor().Function Movement()Step 1.If currentFloor value > floors value, goto step 2 else goto step 7.Step 2.Display message “going down”
Document Related to JAVA Programming_3
3JAVA PROGRAMMINGStep 3.While currentFloor value is > or currentFloor= floors value then goto nextstep, else goto step 6.Step 4.Display currentFloor value.Step 5.Decrease currentFloor by 1, goto step 3.Step 6.Increase currentFloor value by 1, once. Goto step 12Step 7.Display message “going up”Step 8.While currentFloor value < or = floors value goto next step, else goto step 11.Step 9.Display currentFloor value.Step 10.Increase currentFloor by 1, goto step 8.Step 11.Decrease currentFloor value by 1, once. Goto step 12Step 12.End of function Movement().Function FireAlarm()Step 1.Declare function FireAlarm().Step 2.Display danger message.Step 3.If currentFloor value is not 1 goto next step, else goto step 8.Step 4.Print “going down message”Step 5.While currentFloor > or = 1, goto next step else step 7.Step 6.Display currentFloor value and decrease currentFloor value by 1, goto step 5.Step 7.Increase currentFloor value by 1, once.Step 8.End of function FireAlarm().STOPSource Codepackage elevatorsim;import java.io.*;
Document Related to JAVA Programming_4

End of preview

Want to access all the pages? Upload your documents or become a member.

Related Documents
Programming in Java Assignment
|15
|2137
|33

Temperature Recording Program: Java Implementation for Daily and Weekly Temperature Tracking
|7
|1100
|494

Java Programming Assignment: Comma-Separated Integer Inputs and Exception Handling
|8
|937
|481

Major Steps for Solving the Problem
|2
|528
|11

BookStore Application - Assignment
|38
|4445
|25

Memory Sequence Game - Java Program for Console Based Game
|8
|998
|259