Arrays of any size, Computer Engineering

Assignment Help:

Modify your program so that the line "int numStones = ui.readStones();" in the Game constructor is considered. Depending on the value of numStones read from the user, you should create an array of stones of that size. For example, if numStones is 5, rather than 4, you should create an array of stones of size 5, rather than 4. For any given number of stones, the treasure chest should always be placed just to the right of the last stone, at position numStones+1.

You may assume that the user will enter at least 3 stones, and no more than 8 stones. You do not need to check that the user input is within range. The symbols for stones 1-8 are respectively #, @, %, $, !, ^, *, ~.

The formula for unlocking the combination of the treasure is the same as assignment1, but is extended to support any number of stones as follows:

- For 3 stones A,B,C the combination to unlock the treasure is A+B (ignoring C)

- For 4 stones A,B,C,D the combination is (A+B)*C

- For 5 stones A,B,C,D,E the combination is (A+B)*C+D

- For 6 stones A,B,C,D,E,F the combination is ((A+B)*C+D)*E

- For 7 stones A,B,C,D,E,F,G the combination is ((A+B)*C+D)*E+F

- For 8 stones A,B,C,D,E,F,G,H the combination is (((A+B)*C+D)*E+F)*G

Note: You will be penalised for using a long cascading if/else statement. Instead, you should

use a loop that successively adds and multiplies the numeric values of the stones placed in the treasure chest.

Submit to PLATE at any time to receive marks and feedback. Note that it is possible to receive partial marks for a partially working solution.


Related Discussions:- Arrays of any size

Explain indirect cycle in control unit, Q. Explain Indirect Cycle in contro...

Q. Explain Indirect Cycle in control unit? Once an instruction is fetched the subsequent step is to fetch the operands. The instruction may have indirect and direct addressing

Computational study of a spring-mass system, Idealized spring-mass systems ...

Idealized spring-mass systems have numerous applications throughout engineering. Fig.1 shows an arrangement of three masses and four springs which, after is released, is pulled dow

Comparison between centralized and distributed spc, Explain the principles ...

Explain the principles of operation of centralized SPC and distributed SPC and compare their performance. All the control equipment is replaced with a single processor that mus

Telnet services, java program for implementation of telnet services

java program for implementation of telnet services

How are the function code handles in flow logic, How are the function code ...

How are the function code handles in Flow Logic? When the User selects a function in a transaction, the system copies the function code into a           specially   designated

Explain what is the difference among isr & function call, In ISR there is n...

In ISR there is no return value but in function call there is return value

Difference b/w non-relocatable and relocatable programs, Differentiate bet...

Differentiate between non-relocatable and relocatable programs. A non-relocatable program is one which cannot be executed in any memory area other than the area starting at i

Explain the life cycle of a process, Explain the life cycle of a process ...

Explain the life cycle of a process Each procedure has a life cycle, which consists of execution, creation and termination phases of the procedure.  A method may create severa

Specifying optimisation criteria of describe function, Specifying Optimisat...

Specifying Optimisation Criteria Specify values to be minimized, maximized or optimized. You can understand it as way you normalize data in database. For instance, you should

Reprographic methods for information distribution, Reprographic Methods ...

Reprographic Methods i) Thermography ii) Dyeline jii) Microfiche iv) Fax In this unit you have learnt that: Used for Methods of reprography are used for the

Write Your Message!

Captcha
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