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

How to make frames for web documents, Q. How to make frames for web documen...

Q. How to make frames for web documents? Intelligent use of frames can give your pages a cleaner look and make easier to navigate. The fundamental concept goes like this: Every

What is the accessibility testing, Accessibility testing for web sites is a...

Accessibility testing for web sites is a service that can give much more than the standard point-by-point testing methods of most automated services.

What is the application of e-commerce in home shopping, What is the applica...

What is the application of E-Commerce in Home Shopping? Application of E-Commerce in Home Shopping: Television broadcast of goods for purchase sent it directly to a viewe

How can we pass selection and parameter data to a report, How can we pass s...

How can we pass selection and parameter data to a report? There are three options for passing selection and parameter data to the report. Using SUBMIT...WITH Using a rep

How atoms differ from the arrangement of atoms in a liquid, Q. How does the...

Q. How does the preparation of atoms in mainly solids differ from the arrangement of atoms in a liquid? Answer:- The arrangement of atoms in solids are diverse from those

Table - tr and td tags, Table, TR and TD Tags Three tags form the essen...

Table, TR and TD Tags Three tags form the essential ingredients for creating a table. TABLE: This is the main tag. It tells the browser that a table follows. It has attrib

Database management system, what is time out based schemes in concurrency c...

what is time out based schemes in concurrency control

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