Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

General Instructions Write a program which will add digit strings. The input strings will be read Byte objects. The program will evaluate the sum of

General Instructions

Write a program which will add digit strings. The input strings will be read Byte objects. The program will evaluate the sum of each byte pair. The program will write each input pair as well as the results to an output file according to the format specified below. The results will include meaningful messages about erroneous string input or addition overflow when applicable. The program will continue to read and evaluate strings until the end of the input file is reached. You will need to define Byte as a class. The input format is given at the bottom of the page.

Special Instructions

This assignment should be written as a two class Java program. You will develop a class called Byte. The main program should be in its own class with a main method. You are to handle additions of both positive and negative binary strings with the following assumptions: the first string is stored using two's complement and the second using 8-bit biased notation. The result should be a bit string in two's complement (including a decimal interpretation of the result). To keep track of overflow keep the following scenarios in mind:

1)Adding a positive and a negative cannot create overflow.

2)Adding two positives can create over flow, indicated when the highest order bit of the result is 1 after the operation.

3)Adding two negatives can create underflow, indicated when the highest order bit of the result is 0 after the operation.

It is recommended that you define the following Byte class similar to the

following declared class. A suggested Byte declaration is given below.

public class Byte

{

private char[] bits;

public Byte()

{...}

public Byte(char[] bits)

{...}

public Byte(Byte b)

{...}

public Byte add (Byte b)

{...}

public Byte to2sComplement ()

{...}

public Byte biasTo2sComplement ()

{...}

public int magnitude ()

{...}

public String toString ()

{...}

}

Java using Neatbeans Please

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

Students also viewed these Databases questions