Heptadeca class that encapsulates a heptadeca number

Assignment Help Basic Computer Science
Reference no: EM13164939

Write a Heptadeca class that encapsulates a Heptadeca number value. A Heptadeca number is one with 17 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G. The methods the class has are: public void read(), public void set(String), public void set(int), public void set(Heptadeca),public Heptadeca get(), public Heptadeca add(Heptadeca), public Heptadeca subtract(Heptadeca), public Heptadeca multiply(Heptadeca), public Heptadeca divide(Heptadeca), public Heptadeca add(int), public Heptadeca subtract(int), public Heptadeca multiply(int), public Heptadeca divide(int), public Heptadeca add(String), public Heptadeca subtract(String), public Heptadeca multiply(String), public Heptadeca divide(String), public boolean equals(Heptadeca), and public String toString(). Write private methods to check for valid character input, remove the base h character and set the sign. Your class must consider both positive and negative values. Your class should have at least 3 constructors: a default constructor, an explicit constructor with an integer argument and an explicit constructor with a String argument. I will provide a main program as the demo. Recall the nature of numbers and their construction. 13710 is 1 * 102 + 3 * 101 + 7 * 100. In the same way 1A917 would be 1 * 172 + 10* 171 + 9 * 170. Given the decimal number 13710 the digits can be determined using the integer operators / and %. 137 % 10 gives the 7, 137/10 gives 13. 13%10 gives 3 and 13/10 gives 1. 1%10 gives 1 and 1/10 gives 0. The digits base 10 of 137 are 1, 3, 7. The number 13710 converted to base 5 would be 137%5 that gives 2, 137/5 gives 27. 27%5 gives 2, 27/5 gives 5. 5%5 gives 0, 5/5 gives 1. 1%5 gives 1 and 1/5 gives 0. This gives the base 5 number 10225. 13710 converted to base 17 would be 137%17 gives 1, 137/17 gives 8. 8%17 gives 8 and 8/17 gives 0. The number 13710 is therefore 8117.  

this is demo class

public class HeptadecaDemo
{
        public static void main(String[] args)
        {
                Heptadeca heptadeca1 = new Heptadeca ("123h");
                Heptadeca heptadeca2 = new Heptadeca ("123h");
                Heptadeca heptadeca4, heptadeca5, heptadeca6, heptadeca7;
                Heptadeca heptadeca8 = new Heptadeca(1999);
                System.out.println ("Heptadeca  
number heptadeca8: " + heptadeca8); System.out.println ("First Heptadeca
 number: " + heptadeca1); System.out.println ("Second Heptadeca number: " +
 heptadeca2); if (heptadeca1.equals(heptadeca2)) System.out.println ("heptadeca1 and
heptadeca2 are equal."); else System.out.println ("heptadeca1 and
heptadeca2 are NOT equal."); heptadeca4 = heptadeca1.add(heptadeca2); heptadeca5 = heptadeca1.subtract(heptadeca2); heptadeca6 = heptadeca1.multiply(heptadeca2); heptadeca7 = heptadeca1.divide(heptadeca2); System.out.println (heptadeca1 + " + " +
heptadeca2 + " is: " + heptadeca4); System.out.println (heptadeca1 + " - " +
heptadeca2 + " is: " + heptadeca5); System.out.println (heptadeca1 + " * " +
heptadeca2 + " is: " + heptadeca6); System.out.println (heptadeca1 + " / " +
 heptadeca2 + " is: " + heptadeca7); System.out.println (); int number = 6; System.out.println ("using the integer " + number +
 " as the argument " + "to the math operators "); heptadeca4 = heptadeca1.add(number); heptadeca5 = heptadeca1.subtract(number); heptadeca6 = heptadeca1.multiply(number); heptadeca7 = heptadeca1.divide(number); System.out.println (heptadeca1 + " + " + number +
 " is: " + heptadeca4); System.out.println (heptadeca1 + " - " + number +
 " is: " + heptadeca5); System.out.println (heptadeca1 + " * " + number +
 " is: " + heptadeca6); System.out.println (heptadeca1 + " / " + number +
 " is: " + heptadeca7); String value = "6h"; System.out.println ("using the String " + "\"" + value
+ "\"" + " as the argument " + "to the math operators "); heptadeca4 = heptadeca1.add(value); heptadeca5 = heptadeca1.subtract(value); heptadeca6 = heptadeca1.multiply(value); heptadeca7 = heptadeca1.divide(value); System.out.println (heptadeca1 + " + " + value +
 " is: " + heptadeca4); System.out.println (heptadeca1 + " - " + value +
 " is: " + heptadeca5); System.out.println (heptadeca1 + " * " + value +
 " is: " + heptadeca6); System.out.println (heptadeca1 + " / " + value +
 " is: " + heptadeca7); } }

Verified Expert

The assignment was to implement a heptadecimal number which is a number system of base 17.Value supplied should be validated and it should initialize properly if decimal value is supplied ya heptdecimal value is supplied. It should also do operations like addition,subtraction,multiplication and division irrespective of the operand specified.It also checks the equality of two heptadecimal numbers.

Reference no: EM13164939

Questions Cloud

Calculate the percent yield if the actual yield : Calculate the percent yield if the actual yield of aluminum oxide is 0.423mol.
What is the composition of vapor of a pentane-hexane : what is the composition of vapor of a pentane-hexane solution that has a vapor pressure of 373 torr at 25 degree celcius? Given is Pure Hexanes and pentanes vapor pressure at 25 degrees celcius. Pentane - 511 torr. Hexane -150 torr.
Geographical reach-local-regional and global : How would you describe the appropriate target market(s) for Banyan Tree?  How wide is its geographical reach-local, regional, global?
Draw a rough sketch of the energy profile : Draw a rough sketch of the energy profile for each of the following cases. a. E = +10 kJ/mol, Ea = 25 kJ/mol b. E = -10 kJ/mol, Ea = 50 kJ/mol c.
Heptadeca class that encapsulates a heptadeca number : Write a Heptadeca class that encapsulates a Heptadeca number value. A Heptadeca number is one with 17 digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F, G. The methods the class has are: public void read(), public void set(String), public voi..
Determine the present value of the lease payments : Determine the present value of the lease payments at June 30, 2013 (to the nearest $000) that Georgia-Atlantic uses to record the leased asset and lease liability.
Design a java program that has two parallel arrays : Design a java program that has two parallel arrays: a string array named people that is initialized with the names of seven of your friends, and a string array named phoneNumbers that is initialized with your friends phone numbers.
What is the molar mass of the unknown gas : A sample of helium effuses through a porous container 6.5 times faster than does unknown gas X?
Classify the preceding costs as either fixed and variable : Hand-Made Furniture Company manufactures sofas for distribution to several major retail chains and insurance premiums on property, plant, and equipment, $25,000 per year plus $25 per $25,000 of insured value over $16,000,00

Reviews

inf164939

12/6/2016 6:59:03 AM

Thanks a lot, i was bit worried as it was first occasion when i was using your service. But when i looked at the coding, it is fabulous, really. It worked without any error in system. great guys. You are really good. thanks a lot.

inf164939

12/6/2016 6:57:19 AM

When can I receive the solutions? Since this is an old question, can I get it today? Thanks. Hi, I would like to look at the answer please. i need your help in making this assignment of Heptadeca. i am getting confused in it.So pls help me also i need it urgently.

Write a Review

Basic Computer Science Questions & Answers

  How many different seven-digit phone numbers can be formed

How many different seven-digit phone numbers (ignoring area code) can be formed? Can city of 2 million people be served by single area code? Describe.

  Convert hexadecimal number into unpacked bcd number

Convert any hexadecimal number from 00 to 63h placed in AX into its equivalent unpacked BCD number in AX. Multiply byte in register AL by byte in register BL. Place result in AX.

  Explain how company wants corporation-s business

The company is willing to pay $30,000 for the hardware and the software together and wants the complete software product in 4 weeks. What do you tell him? Bear in mind that your company wants his corporation's business, no matter how unreasona..

  Explaining initial values of cache tags and cache lines

Assuming that the initial values of the cache tags and the cache lines are completely arbitrary, Also, show how the cache tags will change for each of the above steps. You should justify your answer.

  Early proof of concept

Currently our organisation has a sample running application to sell books which has been designed as an early proof of concept. The application can be found in your installation at C:glassfish3glassfishdocsjavaee-tutorialexamplescase-studiesdukes-boo..

  Create flowchart and psuedo code for math program

Create flowchart and psuedo code for math program which permits the user to enter two separate numbers and choose one of four mathematical operations (add, subtract, mutiply, divide).

  How components of computer system interact in system

How do components of computer system interact within system? What improvements or additions to system do you believe would benefit you or make system more user-friendly?

  Web forms controls

Using Web Forms controls,create a Web application to include a TextBox object,a Button object,and a ListBox object. Allow the user to input values into the TextBox.Use those values to populate the ListBox object.

  Algorithm beginning of new talk-time-stamps of rtp packets

Explain the algorithm which uses sequence numbers and time stamps of RTP packets to show the beginning of new talk spurt?

  Database redesign is working properly in redesign testing

To make sure that database redesign is working properly during redesign testing process, a means should be created to do which of the following?

  Deduce closed-form expression-estimates-linear regression

In weighted least-squares linear regression, we have weight ri corresponding to each data measurement. Deduce closed-form expression for estimates of w and b which minimize objective function.

  Financial impact of change on wvu students

Currently, PRT riders who are not WVU students or employees must pay $0.50 per trip. Assume that this charge was eliminated.

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