ELEBIYO TOME, RUBEN. BSIT.
10/05/24
SANTOS, OLYN DARIANE
Source Code:
Import [Link];
// opens the class and declares the main method and scanner
Public class DecimalToBinaryCalculator {
Public static void main(String[] args) {
Scanner scanner = new Scanner([Link]);
// Starts asking for the decimal number unless the word “STOP”
is entered
For (;;) {
[Link](“Please enter a decimal number (insert
‘STOP’ to exit): “);
String userInput = [Link]();
If ([Link](“STOP”)) {
[Link](“Program terminated, thanks for using
^.^”);
Break; // Exit the loop
//excecutes the code that can have an exception, in that
case: e
Try {
Int decimalNumber = [Link](userInput);
String binaryNumber =
[Link](decimalNumber); // Converts the decimal
number to binary
[Link](“Decimal: “ + decimalNumber + “ =>
Binary: “ + binaryNumber);
// if we have an exception, that will handle it correctly
} catch (NumberFormatException e) {
[Link](“Invalid input! Please enter a valid
decimal number or ‘STOP’.”);
// Closes the scanner
[Link]();
//end of the class
PROOF SCREENSHOTS: