Design and implement two classes that define progression

Assignment Help Computer Engineering
Reference no: EM132094005

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.

Reference no: EM132094005

Questions Cloud

Contemporary leadership competencies : You have become comfortable with contemporary leadership competencies and feel it is time to open your own small business. As a future business
Discuss how employers can justify the use of tools : Privacy goes hand in hand with security, but many of the activities of information security analysts seem to be an invasion of privacy.
Expected results of implementing your communication plan : You will need to review the products you created and describe what those products are and how they work together. A conclusion that specifies the expected
Explain what communication-conflict management : Explain what communication/conflict management strategy would be effective to eliminate anger felt by the two directors not chosen?
Design and implement two classes that define progression : A numeric progression is a sequence of numbers, where each number depends on one or more of previous numbers.
Some additional context for the feasibility analysis : Feasibility Analysis: The purpose of this analysis is whether or not to add more or less resources in a business model.
Would you approve the proposed strategy : Post a polished and integrated analysis that answers this question: If you were on the board of directors at The Weather Company in 2013
Which command do you use to restart server core : You approach one of your servers running Server Core and see a completely blank desktop except for the mouse pointer.
Formulate an lp to answer question : We have decided to impose variety by having a limit on the number of servings/day for each of our six foods. What is the least cost satisfactory diet?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

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