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
Explain Session Layer of OSI Model. The session layer manages, establishes and terminates communication sessions. Communication sessions contain service of requests and serv

Which scheduling policy is most suitable for a time-shared operating system? Ans. Round-Robin scheduling policy is most appropriate for a time-shared operating system.

Arbitrary categorisation - learning decision trees: Through visualising  a set of boxes with some balls in. There if all the balls were in a single box so this would be nicely

In a two stage network there are 512 inlets and outlets, r=s=24. If the probability that a given inlet is active is 0.8, calculate: the switching elements Given: N =M =512,

Suupose a stack-oriented processor that haves the stack operations PUSH and POP.  Arithmetic operations automatically involve the top one or two stack elements. Starting with an

Describe queue? Ans:  It is a type of data structure in which the data are stored in and retrieved on a First in first out (FIFO) basis. It grows in the direction of increasin

Define the types Programmable logic devices? There are mostly three types PLDs. These are vary in the placement of fuses in the AND- OR array. 1. ROM- It has fixed AND array

Search in Problem Solving: If Artificial Intelligence can inform that the other science about anything, it is about problem solving and, in particular, how to research after s

How will you form an 8 bit adder using 2 four bit adder IC's 7483? Ans: 4 bit adder IC is IC 7483. This has two four bit data inputs and output carry, 4 bit data output carr

Artificial Neural Networks: However imagine now in this example as the inputs to our function were arrays of pixels and there actually taken from photographs of vehicles such