0% found this document useful (0 votes)
50 views3 pages

File: /Home/Abel/Pgm2/Obregona - Ospgm2.Java Page 1 of 3: Import Import Import Import Import Import

This document contains the source code for a Java program that converts between hexadecimal, binary, and chip number representations. It includes methods to convert a hexadecimal string to a binary string array, convert a binary string to a decimal number, and determine the chip number corresponding to a decimal number. The main method reads and prints lines from a file containing hexadecimal values.

Uploaded by

Abel Obregon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
50 views3 pages

File: /Home/Abel/Pgm2/Obregona - Ospgm2.Java Page 1 of 3: Import Import Import Import Import Import

This document contains the source code for a Java program that converts between hexadecimal, binary, and chip number representations. It includes methods to convert a hexadecimal string to a binary string array, convert a binary string to a decimal number, and determine the chip number corresponding to a decimal number. The main method reads and prints lines from a file containing hexadecimal values.

Uploaded by

Abel Obregon
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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 [Link];
import [Link];
import [Link];
import [Link];
import [Link];
import [Link].*;

public class ObregonA_OSpgm2


{
private static String[] hexToBin(String hexNumIn)
{
String[] hexConverted = new String[[Link]()];
String hex = "";
for (int z = 0; z < [Link](); z++)

{
char number = [Link](z);
hex = [Link](number);
if ([Link]("A"))
{
hexConverted[z] = "1010";
}
if ([Link]("B"))
{
hexConverted[z] = "1011";
}
if ([Link]("C"))
{
hexConverted[z] = "1100";
}
if ([Link]("D"))
{
hexConverted[z] = "1101";
}
if ([Link]("E"))
{
hexConverted[z] = "1110";
}
if ([Link]("F"))
{
hexConverted[z] = "1111";
}
if ([Link]("1"))
{
hexConverted[z] = "1";
}
if ([Link]("2")) {
File: /home/abel/pgm2/ObregonA_OSpgm2.java Page 2 of 3

hexConverted[z] = "10";
}
if ([Link]("3"))
{
hexConverted[z] = "11";
}
if ([Link]("4"))
{
hexConverted[z] = "100";
}
if ([Link]("5"))
{
hexConverted[z] = "101";
}
if ([Link]("6"))
{
hexConverted[z] = "110";
}
if ([Link]("7"))
{
hexConverted[z] = "111";
}
if ([Link]("8"))
{
hexConverted[z] = "1000";
}
if ([Link]("9"))
{
hexConverted[z] = "1001";
}
}
return hexConverted;
}

private static double binaryToDecimal(String binary)


{
double number = 0;
for (int i=0; i<[Link](); i++)
{

if([Link](i)=='1')
{
number=number+[Link](2,[Link]()-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 = [Link]()) !=null)
[Link]("%s\n", hex);
}

You might also like