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
to develop an adaptive concept map providing personalized learning for Operating System subject with text file(in any form like html,ppt,txt,doc,pdf)as input

Association and classes betwnn student and university Association and classes are alike in the sense that classes describe objects, and association describe links. Figure shows

(a) Write short notes on displacement only addressing mode. (b) Explain the formats of a 80-bit floating point number. (c) Given the following assembly program. Instructi

A chart illustrating the differences among the new cloud-based technologies (Workday) and the traditional . a. The new cloud-based solutions benefit Workday from every facet wh

1. Click Tools > General Options, and then click the Object Mapping tab. 2. From the Object type list, select the standard object type that is associated with the object class

After going through details of device interfaces next point to be discussed is how the interface can be used to support I/O from devices. Binary information received from an extern

What is a parallel port? A parallel port transfers data in the form a number of bits, typically 8 to 16, concurrently to or from the device.

Q. What is disk access time? The disk access time has two key components: Seek Time: Seek time is the time for disk arm to move heads to the cylinder comprising the desi

(a) Explain, using suitable examples, the functions of each of the sub system mentioned in the context of a large chain of supermarkets (i) Database Management Subsystem (ii)

What is memory mapped I/O? When the I/O devices share the similar address space, the arrangement is known as memory mapped I/O.