Derive a class from longinteger called hexinteger

Assignment Help JAVA Programming
Reference no: EM131479593

JAVA Assignment: Inheritance and Exceptions Binary, Octal, Decimal and Hexadecimal.

A Desktop Calculator Emulator

Create a base class LongInteger that represents a single long integer value in decimal (base 10). The class should have methods that allow you to add, subtract, multiply, and divide two LongInteger objects. Each of these methods should return a new LongInteger object or modify an existing LongInteger. There should also be get and set methods to allow the value of the integer to be changed. Implement a toString() which returns the string representation of the integer in the appropriate base.

Derive a class from LongInteger called BinaryInteger, which is a binary version of LongInteger.

It should be able to do all the things LongInteger does (add, subtract, multiply, divide) by means of inheritance. Of course, the toString method needs to return a binary number in string format.

Derive a class from LongInteger called OctalInteger, which is a base 8 version of LongInteger. As with BinaryInteger, OctalInteger should have add, subtract, multiply, divide methods through inheritance. It should also have its own toString.

Derive a class from LongInteger called HexInteger, which is a hexadecimal (base 16) version of LongInteger with the same attributes and methods as the others. It should also have its own toString.

Create a class IntDriver which will contain a main method. The class should do the following:

1. Present the user with a display that allows them to select one of the above four modes. The user is then supposed to enter a number of that type. If the number they enter is not of the specified type, throw an exception to handle it. The type of exception you throw is up to you, but you should include the type of number expected and the input the user entered. This information should be printed to the screen (ex: BinaryInteger expected, user entered 1010102). The user should then be re-prompted for an integer of the chosen type.

2. Enter an operator (+, -, * or /)

3. Enter a second number.

4. Enter "=" to perform the calculation and display the result.

Decimal mode
Bin - Binary +
Oct - Octal -
Dcm - Decimal *
Hex - Hexadecimal /
Q -Quit =
Option or value --> oct
Octal mode
Bin - Binary +
Oct - Octal -
Dcm - Decimal *
Hex - Hexadecimal /
Q -Quit =
Option or value --> 675
Octal mode
675 (octal)
Bin - Binary +
Oct - Octal -
Dcm - Decimal *
Hex - Hexadecimal /
Q -Quit =
Option or value --> +
Octal mode
675 (octal) +
Bin - Binary +

Oct - Octal -

Dcm - Decimal *

Hex - Hexadecimal /
Q -Quit =
Option or value --> 765
Octal mode
675 (octal) + 765 (octal)
Bin - Binary +
Oct - Octal -
Dcm - Decimal *
Hex - Hexadecimal /
Q -Quit =
Option or value --> =
Octal mode
1662 (octal)
Bin - Binary +

Oct - Octal -

Dcm - Decima *
Hex - Hexadecimal /
Q -Quit =
Option or value --> Q
(Additional)

Be sure to state that you're attempting your work in the comments at the top of your IntDriver.java file.

• Enhance your calculator to handle negative values .
• Write your own methods to convert to and from decimal to binary, octal and hex.

Reference no: EM131479593

Questions Cloud

Discuss the project risk management processes : At this point in the class you have been exposed to several ideas, concepts and strategy regarding risk management. Taking what you have learned so far.
What events led to ishi being the last survivor : What valuable information other than language did Ishi provide for researchers that they would not have otherwise been able to obtain?
Steady-state probabilities of soft drink selection : Suppose a customer just purchased a Pepsi-Cola product. What is the average number of times that customer will purchase either a Coca-Cola product.
What is the objective of the communication : In any project proposal that has been made to the client. Analyze it as a piece of communication. What is the objective of the communication?
Derive a class from longinteger called hexinteger : Derive a class from LongInteger called HexInteger, which is a hexadecimal (base 16) version of LongInteger with the same attributes and methods as the others.
Explain the strategies of functional business corporate : Explain what particular strategies are being used at functional business corporate or international levels to gain comparative advantage in the current.
Outline the most meaningful concepts for management : Outline the most meaningful concepts for Management and Organizational Behavior
Evaluate the participants demonstration of listening : As you think about the conversation, you will evaluate the participants demonstration of listening and responding skills and ability to give feedback.
Explain what an investment banker does : This assignment will assess the following competency 7. Analyze the impact on organizational financial position of accounts receivable, inventory.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Explain how cookies are used to implement sessions

Describe a set of four methods that a queue would need to implement using a circular array and show the Java code to implement them if using an implementation given the outline definition below. Do not use any methods of the Collection classes.

  How the subcomponents of the system work together

You need to have some scenarios of how the user may interact with the system and how the subcomponents of the system work together.

  Describe the differences between relative and linear layouts

Describe the differences between relative and linear layouts. Why are .png files the preferred type of image resource for the Android device? Write a paragraph that gives at least three reasons.

  Write a program that converts number from binary to decimal

write a program that Converts a Number from Binary to Decimal  by using reading keyboard input.

  Write a method called drawspokes to draw the spokes

Write a method drawForest that draws the trees using the method drawTree from Part B. The method takes as a parameter the number of trees to draw

  Find the appropriate bucket

Modify Entry to include the extra field for the next reference. The method findIndex will need to utilize a hash value to find the appropriate bucket. Methods bucketGet and bucketPut will need to walk through the list as necessary looking for a ke..

  standard graph with four quadrant

Write a program in java that asks the user for values of x and y, and displays the point as an ordered pair along with a message that describes where that point falls on the standard graph with four quadrant.

  Create an application in which a user can enter a phone book

Create an application in which a user can enter a phone book entry, including the subsequent elements: First Name, Last Name, Phone Number, email address

  Temporarily move to the street so that the

Driveway is a "last-in, first-out" stack. Of course, when a car owner retrieves a vehicle that wasn't the last one in, the cars blocking it must temporarily move to the street so that the requested vehicle can leave

  Write a java applet that views staff information

Write a Java applet that views, inserts, and updates staff information stored in a table Staff in an Oracle Database. The View button displays a record with a specified ID

  Create an abstract class named element

Part 1: Create an abstract class named Element that holds properties of elements, including their symbol, atomic number, and atomic weight. Include a constructor that requires values for all three properties and a get method for each value.

  How many states are there and draw and label the states

How many states are there and draw and label the states (with variable values) and transitions (with method names). Notice that all of the methods are total.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd