Archibald Haddock (123456789) COMP-202A, Section 0 (Fall 2010) Instructor: Cuthbert Calculus Assignment 3, Question 1a Point A: decimal local var input local var args formal param Point B decimal formal param hex local var Point C decimal formal param hex local var hexValue local var Point D decimal formal param hex local var import java.util.Scanner; public class Decimal2HexConversion { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.print("Enter a decimal number: "); int decimal = input.nextInt(); /* Point A */ System.out.println("The hex number for decimal " + decimal + " is " + decimalToHex(decimal)); } public static String decimalToHex(int decimal) { String hex = ""; while (decimal != 0) { /* Point B */ int hexValue = decimal % 16; hex = toHexChar(hexValue) + hex; decimal = decimal / 16; /* Point C */ } /* Point D */ return hex; } public static char toHexChar(int hexValue) { if (hexValue <= 9 && hexValue >= 0) return (char)(hexValue + '0'); else return (char)(hexValue - 10 + 'A'); }