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. 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

In a particular exchange during busy hour 1200 calls were offered to a group of trunks, during this time 6 calls were lost. The average call duration being 3 minutes Calculate Tr

Binning process is very helpful to save space. Performance may differ depending upon the query generated sometimes solution to a query can come within some seconds and sometimes it

. NET is Compile Time OR RunTime Environment?   .Net's framework has CLS,CTS and CLR.CTS checks declaration of types at the time when u write code and CLS explains some rules a

Extranets can be also used to connect an intranet to Internet so that remote offsite access can be made in a company's intranet by an authorized individual. This can facilitate thr

Given a four level hierarchical storage system consisting of: cache,  primary storage, secondary storage, and tertiary storage. Suppose the following:  programs may be executed on

Implement the Y(A, B, C) = ∑(2,3,5,6) function using 4-to-1 multiplexer.   Ans. Y(A,B,C)=∑(2,3,5,6) Here we take B,C as the select bits also A as input. To select the input we can

Q. How to calculate register indirect addressing? The effective address of operand in this technique is calculated as: EA= (R) and D = (EA)  Address capability of regi

Project Description: I want to prepare website for my party venue where i can post the photos and detail of place along with availability calendar. In future, I buy some more ha

Q. Define the Refresh Rates and frame rate? A special circuit known as the Video Controller scans video memory one row at a time and reads data value at each address sending th