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

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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