Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this assignment. These are the numbers in the RAMerrors file: 3CDAEFFAD ABCDEFABC 7A0EDF301 1A00D0000 Create the folder program2 In this folder place

Need help with this assignment. These are the numbers in the RAMerrors file: 3CDAEFFAD ABCDEFABC 7A0EDF301 1A00D0000 Create the folder program2 In this folder place the text file located on my faculty website in Module 2 called RAMerrors (Do not rename this file, it has no extension and should have no extension.) Each record in this file represents the possible location of an error found in RAM. (Hint: One of them is not on one of the chips.) Assume you have a computer with 4 gigs of RAM, each gig in a different memory chip, therefore you have 4 one gig RAM chips. image text in transcribed In the same folder, in terminal mode using an editor, create a Java program to do the following: - Call the Java program MemoryCalculator.java - Open the RAMerrors file - Read each record - Print the RAM memory chip where the error is located for each record *** CREATE YOUR OWN METHODS THAT WILL CONVERT HEX TO BINARY AND BINARY TO DECIMAL *** DO NOT USE JAVA'S AUTOMATIC CONVERSION METHODS This is the code: import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class MemoryCalculator { //retursn a 4bit binary form for given hex char private static String hexToBin(char hex) { int deci = 0; StringBuilder bin = new StringBuilder("0000"); //get decimal value of the hex char if(hex >= '0' && hex = 'a' && hex = 'A' && hex = 0; i--) { char ch = bin.charAt(i); if(ch == '1') decimal += powerOf2;//add the power of 2 only if the char is 1 powerOf2 *= 2; /ext power } return decimal; } public static void main(String[] args) { Scanner keybd = new Scanner(System.in); String filename ; System.out.print("Enter input filename: "); filename = keybd.nextLine(); Scanner inFile = null; try { inFile = new Scanner(new File(filename)); } catch (FileNotFoundException e) { System.out.println(e.

getMessage()); return; } long KB = 1024 * 8; /o. of bits in 1KB long MB = 1024 * KB; /o. of bits in 1MB long GB = 1024 * MB; /o of bits in 1GB while(inFile.hasNext()) { String hex = inFile.next(); String bin = hexToBin(hex); long deci = binToDeci(bin); long chip = deci / GB; System.out.printf("Ram Chip %d, Hex: %s, Decimal: %,d ", chip, hex, deci ); //System.out.print(", Binary " + bin + " "); } inFile.close(); } }

Assume you have a computer with 4 gigs of RAM, each gig in a different memory chip, therefore you have 4 one gig RAM chips -decimal- HINT: RAM chip 0 contain addresses: 0-8,589,934,584 bits RAM chip 1 contain addresses: 8,589,934,585 - 17,179, 869,184 bits RAM chip 2 contain addresses: 17,179,869,185 - 25,769, 803, 768 bits RAM chip 3 contain addresses: 25, 769, 803,769 - 34,359, 738,368 bit:s 01,073,741,823 bytes RAM chip 1 contain addresses: 1,073,741,824-2,147,483,648 bytes 3,221,225,471 bytes RAM chip 3 contain addresses: 3,221,225,472 -4,294,967,296 bytes HINT: RAM chip 0 contain addresses: RAM chip 2 contain addresses: 2,147,483, 647 In the same folder, in terminal mode using an editor, create a rogram to do the following

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago