logo

Fundamentals of Operating Systems and Java Programming

   

Added on  2024-04-26

14 Pages857 Words463 Views
Fundamentals of Operating Systems and
Java Programming
1

Contents
Task 1:..............................................................................................................................................................3
Algorithm:....................................................................................................................................................3
Source code:.................................................................................................................................................4
Screenshots of the output:...........................................................................................................................6
Task 2...............................................................................................................................................................8
Algorithm:....................................................................................................................................................8
Coding screenshots:.....................................................................................................................................9
NIM game output:......................................................................................................................................12
Output after Adding input validation to your Nim program.......................................................................13
References......................................................................................................................................................14
List of Figures
Figure 1 Source code........................................................................................................................................4
Figure 2 welcome message with menu system................................................................................................6
Figure 3: error message for invalid selection....................................................................................................6
Figure 4 for fire alarm selection........................................................................................................................6
Figure 5 invalid floor selection..........................................................................................................................6
Figure 6 for floor number 15............................................................................................................................7
Figure 7 floor number 10 selection...................................................................................................................7
Figure 8 select fire alarm choice after 10-floor selection.................................................................................7
Figure 9 quit the system...................................................................................................................................7
Figure 10 source code screenshots...................................................................................................................9
Figure 11 NIM game output...........................................................................................................................12
Figure 12 Output after Adding input validation to your NIM program...........................................................13
2

Task 1:
Algorithm:
The algorithm describes the logic to solve a program [1]. The algorithm for the task 1 is shown below:
Step 1: Start the program
Step2: Print a welcome message
Step3: print menu system with “s/f/q” choice. ‘s' for the select floor, ‘f' for select fire alarm and ‘q' for quit
the system[3].
Step 4: Ask user to enter a choice
4.1 If user select choice‘s’ then ask user to enter the floor number
4.1.1. if floor number <1 and floor number >100 then print an error message
4.1.2 A. if current floor number is less than previously enter floor number then
Take lift in down direct up to entered floor number
B. else take lift in upward direction up to entered floor number
4.2. if user select choice ’f’ then
4.2.1 check lift is on which floor if it is not on the ground floor then take the lift down to the ground
floor and print a dangerous message.
4.2.2. else print a dangerous message.
4.3 if user select ‘q’ choice then exit the system.
Step 5: end the program
3

Source code:
Figure 1 Source code
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

Document Related to JAVA Programming
|15
|1971
|338

NIM Game Playing Interface in Java
|8
|2250
|180

Assignment on Python Programming
|9
|1384
|74

Programming
|5
|531
|69

ITECH1400 Fundamentals of Programming - Australian Tax Office
|12
|1191
|15