/* HardwareNumbers.java Name: Date: In this assignment, you will complete several number-related challenges inspired by computer hardware concepts. It reviews the following concepts: - Variables - ASCII table, chars, type casting - Strings, ints, doubles - Console input/output - Arithmetic operators (+, -, *, /, %, Math methods) DO NOT use: - Methods - Conditionals (if, switch) - Loops (for, while) - Arrays Follow the instructions and complete each part by writing your code where indicated. Add comments to explain your calculations. */ import java.util.Scanner; public class HardwareNumbers { public static void main(String[] args) { // -------------------------- // Part 1: ASCII Art from Hardware Codes // -------------------------- // Use ASCII values to display "CPU" on one line with spaces. // Example of type casting with ASCII: // int code = 65; // char letter = (char) code; // letter will store 'A' // System.out.println(letter); // Write your code here: // -------------------------- // Part 2: Algorithms with Modulus // -------------------------- // Suppose a memory address is stored as a 5-digit number: 12345 // Print the last digit using the modulus operator (%). // Example: // int number = 12345; // int lastDigit = number % 10; // extracts the last digit // System.out.println(lastDigit); // Then, calculate and print the sum of all digits. // Do it manually using arithmetic operators without loops. // Write your code here: // -------------------------- // Part 3: Integer Overflow Experiment // -------------------------- // Create an int with value Integer.MAX_VALUE (2147483647). // Add 10 to it and print the result. // Write your code here: // Explain what happened in this comment: ___________________ // -------------------------- // Part 4: Round-Off Error in Floating-Point Arithmetic // -------------------------- // Divide 10.0 by 3.0 and then multiply the result by 3.0. // Print the result and observe if it equals 10.0. // Example of floating-point error: // double value = 10.0 / 3.0; // double result = value * 3.0; // System.out.println(result); // Compare with 10.0 // Write your code here: // Explain what happened in this comment: ___________________ // -------------------------- // Part 5: Number Systems in Computing // -------------------------- // Convert binary "1101" to decimal manually using arithmetic operations. // Example: Binary 1101 = (1x2^3) + (1x2^2) + (0x2^1) + (1x2^0) // Use Math.pow(base, exponent) for powers. // Convert hexadecimal "1A" to decimal manually. // Example: Hexadecimal 1A = (1x16^1) + (10x16^0) // Remember, 'A' in hex is 10 in decimal. // Write your code here: } // main } // class