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

Creating a function, I''m suppose to create a function called calc_rectang_...

I''m suppose to create a function called calc_rectang_area(height, width),that takes two parameters: the height and width of the rectangular and return the area of the rectangular.

Explain how server form post-back works, Briefly explain how server form po...

Briefly explain how server form post-back works?  Post Back: The process in which a Web page sends data back to the similar page on the server. View State: View State is the m

Example multi-layer ann with sigmoid units, Example Multi-layer ANN with Si...

Example Multi-layer ANN with Sigmoid Units - Artificial intelligence: We will discuss ourselves here with ANNs containing only 1 hidden layer, as this makes describing the back

Why are binary, Q. Why are binary, octal and hexadecimal used for computer ...

Q. Why are binary, octal and hexadecimal used for computer applications? Q. Perform the following: (189.3) 10 = (?) 2

How does computer know that overflow has happened, Q. How does computer kno...

Q. How does computer know that overflow has happened? Illustration: Add numbers 65 and 75 in 8 bit register in signed 2's complement notation.  Here expected result is

Various ways of floating point representation in memory, Describe the vario...

Describe the various ways of floating point representation in memory. What is the importance of normalizing the mantissa in this representation? Explain it by example(s)?

Last ant on rod, i want program code for the above question in c language

i want program code for the above question in c language

Describe the architecture of electronic data exchange, Describe the Electro...

Describe the Electronic Data Exchange (EDI) architecture in brief. Electronic Data Interchange (EDI) may be generally easy to understand as the replacement of paper-based purch

What is dom, DOM is the Document Object Model (DOM) which is an interface s...

DOM is the Document Object Model (DOM) which is an interface specification handled by the W3C DOM Workgroup that explains an application independent mechanism to access, parse, or

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