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. Evaluate Speed of disk drive? Drive Speed: Amount of information which can be transferred in or out of memory in a second is called as disk drive speed or data transfer ra

What is Circular shift The circular shift is also called as rotate operation. It circulates bits of the register around two ends and there is no loss of information. This is do

Final Implementation of Object oriented modelling Final Implementation: At this phase, the final execution of classes and  relationships developed while object design takes

Why is TCP called end-to-end protocol? TCP is termed as an end-to-end protocol as this provides a connection directly by an application in one computer to an application on a r

Q. How to Transmits data in the active message buffer? int pvm_bcast( char *group, int msgtag ) Transmits data in the active message buffer to a group of processes. msgt

What are pages? All programs and date are composed of fixed length units known as pages. Each page consists of blocks of words that occupy contiguous locations in main memory

Unions allow the same area of memory to be accessed as different data types. The insurance example above would not work. Unions are useful (often in embedded programming) when i

A certain car has suspension modes which are uncoupled front to back.  When a person with a mass of 60 kg sits in the rear of a car, in the centre of the seat which is directly ove

Prove the following identities   a. A ‾B ‾C‾ + A ‾BC ‾ + AB ‾C ‾ + ABC ‾ = C ‾ b. AB + ABC + A ‾ B + AB ‾C = B + AC Ans. a. LHS = A'B'C' + A'BC' + AB'C' + ABC' =

What is User Defined Functions? User-Defined Functions permit defining its own T-SQL functions that can accept 0 or more parameters and return a single scalar data value or a t