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
First-Order Models: Here if we proposed first-order logic as a good knowledge representation language than propositional logic is just because there is more expressive than we

The transport protocol used by TFTP (Trivial File Transfer Protocol) is? The transport protocol used through Trivial File Transfer Protocol is UDP.

Think about call of two intrinsic functions discussed above for a 32-Processor (4×8) Multicomputer:    The function call NUMBER_OF_PROCESORS () will return 32.

Define File record length ? File record length must be selected to match the data characteristics.

Program to transfer 10 byte of data from DMS to EMS using 8086 instructions

Draw the state diagram of a process from its creation to termination, including all transitions, and briefly elaborate every state and every transition. When a process executes

Clipboard is a temporary storage location in Windows. The clipart will kept one piece of information at a time when it is manually added to the clipart or is copied there.

The main aim of using LINQ to Dataset is to run strongly typed queries on Dataset. Assume we want to combine the results from two Datasets, or we need to take a distinct value f

Q. Illustrate control and timing signals? The requirement of I/O from different I/O devices by processor is quite unpredictable. In fact it relies on I/O needs of particular pr

Q. Define looping in assembly language? LOOPING  ; Program: Assume a constant inflation factor that is added to a series of prices ; stored in the memory. The program