File: /home/abel/pgm2/ObregonA_OSpgm2.
java Page 1 of 3
/*********************************************************************
Author : Abel Obregon
Course : Computer Operating Systems for IT 2021 Fall.
Professor : Michael Robinson
Program #2: Convert Hex Value, Binary Value, Chip Number
Due Date : 9/28/2021
Certification:
I hereby certify that this work is my own and none of it is the work of any other person.
..........{ Abel Obregon }..........
*********************************************************************/
import java.util.Scanner;
import java.io.File;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.*;
public class ObregonA_OSpgm2
{
private static String[] hexToBin(String hexNumIn)
{
String[] hexConverted = new String[hexNumIn.length()];
String hex = "";
for (int z = 0; z < hexNumIn.length(); z++)
{
char number = hexNumIn.charAt(z);
hex = String.valueOf(number);
if (hex.equals("A"))
{
hexConverted[z] = "1010";
}
if (hex.equals("B"))
{
hexConverted[z] = "1011";
}
if (hex.equals("C"))
{
hexConverted[z] = "1100";
}
if (hex.equals("D"))
{
hexConverted[z] = "1101";
}
if (hex.equals("E"))
{
hexConverted[z] = "1110";
}
if (hex.equals("F"))
{
hexConverted[z] = "1111";
}
if (hex.equals("1"))
{
hexConverted[z] = "1";
}
if (hex.equals("2")) {
File: /home/abel/pgm2/ObregonA_OSpgm2.java Page 2 of 3
hexConverted[z] = "10";
}
if (hex.equals("3"))
{
hexConverted[z] = "11";
}
if (hex.equals("4"))
{
hexConverted[z] = "100";
}
if (hex.equals("5"))
{
hexConverted[z] = "101";
}
if (hex.equals("6"))
{
hexConverted[z] = "110";
}
if (hex.equals("7"))
{
hexConverted[z] = "111";
}
if (hex.equals("8"))
{
hexConverted[z] = "1000";
}
if (hex.equals("9"))
{
hexConverted[z] = "1001";
}
}
return hexConverted;
}
private static double binaryToDecimal(String binary)
{
double number = 0;
for (int i=0; i<binary.length(); i++)
{
if(binary.charAt(i)=='1')
{
number=number+Math.pow(2,binary.length()-1-i);
}
}
return number;
public int chipNumber(double num)
{
int chip = 0;
if(num>=0 && num<=34359738368l)
{
chip = 0;
}
else if(num>=34359738369l && num<=68719476738l)
{
chip = 1;
File: /home/abel/pgm2/ObregonA_OSpgm2.java Page 3 of 3
}
else if(num>=68719476739l && num<=103079215108l)
{
chip = 2;
}
else if(num>=103079215109l && num<=137438953478l)
{
chip =3;
}
else if(num>=1374389534799l && num<=171798691848l)
{
chip = 4;
}
else if(num>=171798691849l && num<=206158430218l)
{
chip = 5;
}
else if(num>=206158430219l && num<=240518168588l)
{
chip = 6;
}
else
{
chip = 8;
}
return chip;
}
public static void main(String[] args) throws IOException
{
File file = new File("/home/abel/pgm2/RAMerrors8x4f.5");
BufferedReader br = new BufferedReader (new FileReader(file));
String hex = "";
while ((hex = br.readLine()) !=null)
System.out.printf("%s\n", hex);
}