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
Q. Explain about Multi tasking environment? Multi tasking uses parallelism by: 1) Pipelining functional units are pipe line mutually 2) Simultaneously employing multiple

What criteria should be adopted for choosing type of file organization. Selecting a file organization is a design decision; therefore it must be done having in mind the achieve

Which of the best method between linear addressing and matrix addressing modes ? Ans: Best Method: Matrix Addressing is the suitable method, since this configuration on

Given a cell, we must determine its neighbouring cells i.e. those with which it shares a wall. The cells with an x are the neighbours of the cell c. Write the function getneighbour

Q. What is CODE SEGMENT? The logical program segment is termed as code segment. When linker links a program it makes a note in header section of program's executable file defin

Before proceeding with its execution, each process must acquire all the resources it needs is called ? Ans. Hold and Wait is requires in each process should acquire all the res

What is logical address space and physical address space? The set of all logical addresses generated by a program is known as a logical address space; the set of all physical a

Is the basic list deleted when the new list is created? No.  It is not removed and you can return back to it using one of the standard navigation functions like clicking on th

The real power of arrays comes from their facility of using an index variable to traverse the array, accessing every element with the similar expression a[i]. All the is required t

There are three primary colours in pigments - Red, Yellow and Blue. There are two ways to produce more colours:   Physical Mixing: Physically mix colours to produce a new colour