Arrays of any size, Computer Engineering

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.

Posted Date: 3/25/2013 5:50:54 AM | Location : United States







Related Discussions:- Arrays of any size, Assignment Help, Ask Question on Arrays of any size, Get Answer, Expert's Help, Arrays of any size Discussions

Write discussion on Arrays of any size
Your posts are moderated
Related Questions
Standard typewriter : You must have seen this manually operated machine. Standard typewriters of various makes such as Remington, Fact, Godrej, etc., are available in the market.

Q. Illustrate Arithmetic shifts with example? Arithmetic shifts ARITHMETIC SHIFT LEFT and ARITHMETIC SHIFT RIGHT are same as LOGICAL SHIFT LEFT and LOGICAL SHIFT RIGHTexcept th

What is .NET / .NET Framework?  It is a Framework in which Windows applications might be developed and run. The Microsoft .NET Framework is a platform for building, deploying,

Design a MOD-6 synchronous counter using J-K Flip-Flops. Ans: Design of Mod-6 Counter:   To design the Mod-6 synchronous counter, contain six counter states (that is, from

The Process of Development The approach to development can be an iterative one. It involves repeated refinement of the object model. The process needs to be controlled by an a

What is a sparse matrix? Sparse Matrix A matrix in which number of zero entries is much higher than the number of non-zero entries is known as sparse matrix. The natural me

Q. Describe the instruction set architecture? The significant role of the Central Processing Unit (CPU) is to perform calculations, to coordinate all other hardware components,

Q. How to Information transfer from one register to another? Information transfer from one register to another is designated in symbolic notation by a replacement operator. For

Implication connective - Modus ponens rule: We notice that this is a trivial example, so it highlights how we use truth tables: as the first line is the only one when both abo

Consider a network message transfer among a source S and a destination D by 3 routers R1, R2 and R3 as given below:-               S -------- R1 --------- R2 --------- R3 ---