Ask Computer Engineering Expert

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); } }

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9455057

Have any Question?


Related Questions in Computer Engineering

Does bmw have a guided missile corporate culture and

Does BMW have a guided missile corporate culture, and incubator corporate culture, a family corporate culture, or an Eiffel tower corporate culture?

Rebecca borrows 10000 at 18 compounded annually she pays

Rebecca borrows $10,000 at 18% compounded annually. She pays off the loan over a 5-year period with annual payments, starting at year 1. Each successive payment is $700 greater than the previous payment. (a) How much was ...

Jeff decides to start saving some money from this upcoming

Jeff decides to start saving some money from this upcoming month onwards. He decides to save only $500 at first, but each month he will increase the amount invested by $100. He will do it for 60 months (including the fir ...

Suppose you make 30 annual investments in a fund that pays

Suppose you make 30 annual investments in a fund that pays 6% compounded annually. If your first deposit is $7,500 and each successive deposit is 6% greater than the preceding deposit, how much will be in the fund immedi ...

Question -under what circumstances is it ethical if ever to

Question :- Under what circumstances is it ethical, if ever, to use consumer information in marketing research? Explain why you consider it ethical or unethical.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

What type of economic system does norway have explain some

What type of economic system does Norway have? Explain some of the benefits of this system to the country and some of the drawbacks,

Among the who imf and wto which of these governmental

Among the WHO, IMF, and WTO, which of these governmental institutions do you feel has most profoundly shaped healthcare outcomes in low-income countries and why? Please support your reasons with examples and research/doc ...

A real estate developer will build two different types of

A real estate developer will build two different types of apartments in a residential area: one- bedroom apartments and two-bedroom apartments. In addition, the developer will build either a swimming pool or a tennis cou ...

Question what some of the reasons that evolutionary models

Question : What some of the reasons that evolutionary models are considered by many to be the best approach to software development. The response must be typed, single spaced, must be in times new roman font (size 12) an ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As