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

S1 Java Prog Lab5 New

This lab asks students to add number system conversion functionality to an existing calculator application. Specifically, it involves: 1. Creating a NumberSystemConversion class with methods to convert between binary, octal, decimal, and hexadecimal representations. 2. Adding a sixth menu item and submenu to the calculator app for number system conversion. 3. Implementing conversion methods that allow only valid input for each system and display error messages for invalid input, rather than using built-in Java conversion functions.

Uploaded by

Chhay Lay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

S1 Java Prog Lab5 New

This lab asks students to add number system conversion functionality to an existing calculator application. Specifically, it involves: 1. Creating a NumberSystemConversion class with methods to convert between binary, octal, decimal, and hexadecimal representations. 2. Adding a sixth menu item and submenu to the calculator app for number system conversion. 3. Implementing conversion methods that allow only valid input for each system and display error messages for invalid input, rather than using built-in Java conversion functions.

Uploaded by

Chhay Lay
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

សាកលវ ិទ្យាល័យភូមិន្ភ

ទ ំពន េញ Java Programming


មហាវ ិទ្យយល័យវ ិស្វកមម ពោកគ្រូ៖ ពោ ស្ុខជា
ឆ្នទ្យ
ំ ី២ ឆមាស្ទ្យី១ Lab5

LAB 5: ITECalculator
In this lab, you will continue your calculator application by adding the following features:

A. Create a new class named it NumberSystemConversion. The


NumberSystemConversion class will consist of wide ranges of methods to perform
conversion.

B. Please add Javadoc comment to above the class to explain the purpose of this
class and above each method to explain it.

C. In the NumberSystemConversion class, please create the following methods:

1. binary2Decimal(long or int binary) to convert from binary to decimal

2. binary2Octal(long or int binary) to convert from binary to octal

3. binary2Hex(long or int binary) to convert from binary to hexadecimal

4. octal2Decimal(long or int octal) to convert from octal to decimal

5. octal2Binary(long or int octal) to convert from octal to binary

6. octal2Hex(long or int octal) to convert from octal to hexadecimal

D. Please add sixth menu item Number System Conversion to the menu

E. When user chooses menu number 6, it wills show a submenu containing the
following menu

1. Binary

 Binary to Octal
សាកលវ ិទ្យាល័យភូមិន្ភ
ទ ំពន េញ Java Programming
មហាវ ិទ្យយល័យវ ិស្វកមម ពោកគ្រូ៖ ពោ ស្ុខជា
ឆ្នទ្យ
ំ ី២ ឆមាស្ទ្យី១ Lab5
 Binary to Decimal

 Binary to Hexadecimal

Note: In binary, it contains only number 0 and 1. So, please allow the user to input only 0

and 1 if user chooses this submenu. If the user inputs the number beside 0 and 1, please

display a message to inform user that in binary only 0 and 1 is allowed.

2. Octal

 Octal to binary
 Octal to decimal

 Octal to hexadecimal

Note: In octal, it contains only number from 0 to 7. So, please allow the user to input only

from 0 to 7 if user chooses this submenu. If the user inputs the number beside 0 to 7,

please display a message to inform user that in binary only 0 to 7 is allowed.

Note: You cannot use built-in function in Java to perform conversion. You need to

implement the method yourself based on the knowledge you learn in year 1.

You might also like