Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Please answer this question in java

a) Inheritance

A numeric progression is a sequence of numbers, where each number depends on one or more of previous numbers.

Design and implement two classes that define arithmetic and geometric progression.

Start by defining a parent class called Progression. This class should contain the following instance variables :

• first - first value of the progression

• cur - current value of the progression

Both variables should be initialized with values passed into the constructor .

Progression should also have three methods:

• firstValue() - Reset the progression to the first value, and return that value .

• nextValue() -Step the progression to the next value and return that value.

• printProgression(n) - Reset the progression and print the first n values of progression.

Two classes should inherit from Progression:

ArithProgression that defines and prints out an arithmetic progression, where the next value is determined by adding a fixed increment to the previous value. Set the default increment to 1 in the default constructor. Provide setinc() method to set the increment value.

GeomProgression that steps and prints out a geometric progression, where the next value is determined by multiplying the previous value by a fixed base. Set the default base to 2 in the default constructor. Provide setbase() method to set the base value.

Test the classes in a Driver class . In the Driver class ,

Print out the 10 Arithmetic progression with default increment and increment by 5 using constructor. Use setinc method to set increment by 10 and print out 10 Arithmetic progression also.

Print out the 10 Geometric progression with default base, base equal to 3 by using constructor. Use setbase method to set base equal to 5 and print out 10 Geometric progression also.

Computer Engineering, Engineering

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

Have any Question?


Related Questions in Computer Engineering

Question a as we have seen the internet layer of tcpip has

Question : (a) As we have seen, the Internet layer of TCP/IP has two protocols - IPv4 and IPv6. The transport layer provides two main protocols TCP and UDP (along with some special-purpose, minor protocols). But these ar ...

Recursive greatest common divisor the greatest common

(Recursive Greatest Common Divisor) The greatest common divisor of integers x and y is the largest integer that evenly divides both x and y. what is a recursive function gcd that returns the greatest common divisor of x ...

Research the history of specification languages and write a

Research the history of specification languages, and write a report on the successes or failures of some of these languages. Include 5 languages which are successful and 5 which have failed. All work should be typed writ ...

Why software is important in our lifesearch the internet

Why Software is important in our life? Search the internet for "Why Software is important in our life" Read about this topic and write an essay of around 500 words and submit it.

Discuss how the scope of computer security grew from

Discuss how the scope of computer security grew from physical security to include : Securing the data Limiting random and unauthorized access to that data. Involvement of personnel from multiple levels of the organizatio ...

You are running a memory-intensive multimedia application

You are running a memory-intensive multimedia application on your computer, which has 1 GB RAM installed. You observe that the computer momentarily stops responding when you switch between two multimedia applications. 1. ...

Across the nine cities in multilevel multivariate analysis

Across the nine cities, in multilevel, multivariate analysis, controlling for income inequality (GINI coefficient), percent living in poverty and percent Non-Hispanic Black population, the ZIP code level overall HIV diag ...

Question you are in a social situation talking with

Question : You are in a social situation talking with coworkers, friends, or family members who are not familiar with the concept of networking, except for the idea that they turn on their computer and surf the World Wid ...

Question suppose that a store offers gift certificates in

Question : Suppose that a store offers gift certificates in denominations of 25 dollars and 40 dollars. Determine the possible total amounts you can form using these gift certificates. Prove your answer using strong indu ...

Some seem to believe that we should be pure maximizers

Some seem to believe that we should be pure maximizers. Others say that we do better as constrained maximizers. Which view does David Schmidtz endorse and why?

  • 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