Arrays of any size, Computer Engineering

Assignment Help:

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.


Related Discussions:- Arrays of any size

Storing a word in memory - computer architecture, Storing a word in Memory:...

Storing a word in Memory: That is similar process with fetching a word from memory. The required address is loaded into the MAR After that data to be written are lo

Illustrate the full form of ooa, Illustrate the Full form of OOA OOA vi...

Illustrate the Full form of OOA OOA views the world as objects consist of data structures and events that trigger operations and behaviours, for object behaviour changes. The b

Explain session layer of osi model, Explain Session Layer of OSI Model. ...

Explain Session Layer of OSI Model. The session layer manages, establishes and terminates communication sessions. Communication sessions contain service of requests and serv

Calculating block size - computer architecture, Calculating Block Size: ...

Calculating Block Size: B A unit of associatively -one tag for B A words B T unit of transfer-B T words to/from primary memory as a unit             One valid bit for

Define rules for reducing karnaugh maps, Define Rules for Reducing Karnaugh...

Define Rules for Reducing Karnaugh Maps? The rules for reducing Karnaugh Maps (k- maps) are as follows: All of the 1's in the Karnaugh Map are called as minterms. The

Function of host to host transport layer in tcp/ip protocol, Illustrate the...

Illustrate the function of host to host transport layer in TCP/IP protocol stack? Function of Host - to-Host Transport Layer: This protocol layer just above inter network

Explain busy waiting semaphores, Explain busy waiting semaphores. Weak,...

Explain busy waiting semaphores. Weak, Busy-wait Semaphores: The simplest method to implement semaphores. Useful while critical sections last for a short time, or we

Abap/4 dictionary structures without an underlying database, It is not poss...

It is not possible to use ABAP/4 Dictionary Structures without an underlying database using LDB. True.  You can use additionally related tables, along with the tables explaine

Associativity of connectives - equivalences rules, Associativity of Connect...

Associativity of Connectives : Here brackets are very important in order to tell us where to perform calculations in arithmetic and logic. By using these brackets we evaluate

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd