/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.calebfontenot.lab8_calebfontenot;

import java.util.Scanner;

/**
 *
 * @author caleb
 */
public class DecimalToHex2 {

    public static void main(String[] args) {
        // Define vars
        int inputDecimal,
                outputHex = 0x0;

        // Create scanner
        Scanner input = new Scanner(System.in); 
        
        // Prompt for input        
        System.out.print("Enter a decimal value (0-15): ");
        inputDecimal = input.nextInt();
                
        // Switch moment
        if (inputDecimal == 0) {
            outputHex = 0x0;
        } else if (inputDecimal == 1) {
            outputHex = 0x1;
        } else if (inputDecimal == 2) {
            outputHex = 0x2;
        } else if (inputDecimal == 3) {
            outputHex = 0x3;
        } else if (inputDecimal == 4) {
            outputHex = 0x4;
        } else if (inputDecimal == 5) {
            outputHex = 0x5;
        } else if (inputDecimal == 6) {
            outputHex = 0x6;
        } else if (inputDecimal == 7) {
            outputHex = 0x7;
        } else if (inputDecimal == 8) {
            outputHex = 0x8;
        } else if (inputDecimal == 9) {
            outputHex = 0x9;
        } else if (inputDecimal == 10) {
            outputHex = 0xA;
        } else if (inputDecimal == 11) {
            outputHex = 0xB;
        } else if (inputDecimal == 12) {
            outputHex = 0xC;
        } else if (inputDecimal == 13) {
            outputHex = 0xD;
        } else if (inputDecimal == 14) {
            outputHex = 0xE;
        } else if (inputDecimal == 15) {
            outputHex = 0xF;
        }

        // Output
        System.out.println("The hex value is " + String.format("%x", outputHex));
    }
}
