0% found this document useful (0 votes)
28 views

Laboratory Exercise Array Looping

The document provides examples of 3 programming exercises: 1) a number checking program, 2) a chess piece movement program, 3) a word to number amount converter program. It includes sample outputs and notes on creating classes for the chess piece and amount converter programs.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Laboratory Exercise Array Looping

The document provides examples of 3 programming exercises: 1) a number checking program, 2) a chess piece movement program, 3) a word to number amount converter program. It includes sample outputs and notes on creating classes for the chess piece and amount converter programs.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Laboratory Exercise Java Programming

Looping and Array



1. Make a program that will accept integer number and check whether the new inputted number
is already been entered. If the inputted number is zero, the program will close.
Sample Output:
Enter number: 11
11
Enter number: 85
11 85
Enter number: 26
11 85 26
Enter number: 11
11 has already been entered
11 85 26
Enter number: 41
11 85 26 41

2. Make a program that generates a position of the horse piece in a chess board and display all
possible moves of the horse from the generated position. Note: Make a ChessPieceMoves class
with getPossibleMoves(chesspiece,position) that will return the possible moves of the chess
piece as array type and ToString() that will return all the possible moves in a string format.
Sample Output:
Generated Horse Position: E4
A B C D E F G H
8[ ][ ][ ][ ][ ][ ][ ][ ]
7[ ][ ][ ][ ][ ][ ][ ][ ]
6[ ][ ][ ][x][ ][x][ ][ ]
5[ ][ ][x][ ][ ][ ][x][ ]
4[ ][ ][ ][ ][h][ ][ ][ ]
3[ ][ ][x][ ][ ][ ][x][ ]
2[ ][ ][ ][x][ ][x][ ][ ]
1[ ][ ][ ][ ][ ][ ][ ][ ]

3. Make a program that will accept amount in words from zero to three thousand and display
the amount in numerical value. Note: Make a WordAmount class with ToNumeric() that will
return the numerical value of the string that passed to it.
Sample output:
Enter amount in words: one thousand three hundred twenty nine
In numerical value: 1329

You might also like