programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
• Campbell Ritchie
• Jeanne Boyarsky
• Ron McLeod
• Paul Clapham
• Liutauras Vilda
Sheriffs:
• paul wheaton
• Rob Spoor
• Devaka Cooray
Saloon Keepers:
• Stephan van Hulst
• Tim Holloway
• Carey Brown
• Frits Walraven
• Tim Moores
Bartenders:
• Mikalai Zaikin

# adding and removing from an array while conditions are met.

Greenhorn
Posts: 2
• Number of slices to send:
Optional 'thank-you' note:
My problems/needs are commented in my code. Any help would be greatly appreciated. Thank you in advance. My existing code may even be off. I feel like there are so many variables. I just need help lol ... its getting frustrating at this point and my deadline is quickly approaching. I don't need EXACT code, I just need a kick in the ass in the right direction.

The project prompt:

The number of rows they have to stand on. The maximum number of rows is 10. The rows are labelled with capital letters, 'A', 'B', 'C', etc.
For each row, the number of positions in the row. The maximum number of positions is 8. The positions are numbered with integers, 1, 2, 3, etc.
The conductor then starts assigning people to positions, but is constrained by weight limits: Musicians, fully clothed and holding their instruments, weigh from 45kg to 200kg, and the total weight of a row may not exceed 100kg per position (e.g., a row with 5 positions may not have more than 500kg of musicians on it). The conductor wants a program that allows musicians to be added and removed from positions, while ensuring the constraints are all met. At any stage the conductor wants to be able to see the current assignment - the weight in each position (0kg for vacant positions) and the total & average weight for each row.
The program must be menu driven, with options to:

Add a musician (by weight) to a vacant position.
Remove a musician from an occupied position.
Print the current assignment.
Exit (so the musicians can start playing)
The program must be reasonably idiot proof:
Menu options must be accepted in upper and lower case.
Row letters must be accepted in upper and lower case.
All input must be checked to be in range, and if not the user must be asked to input again.
You may assume that numeric input will be syntactically correct.
Here's what a sample run should look like (with the keyboard input shown in italics) ...

Welcome to the Band of the Hour
-------------------------------
Please enter number of rows : 11
ERROR: Out of range, try again : 3
Please enter number of positions in row A : -4
ERROR: Out of range, try again : 3
Please enter number of positions in row B : 4
Please enter number of positions in row C : 5

(A)dd, (R)emove, (P)rint, e(X)it : p

A: 0.0 0.0 0.0 [ 0.0, 0.0]
B: 0.0 0.0 0.0 0.0 [ 0.0, 0.0]
C: 0.0 0.0 0.0 0.0 0.0 [ 0.0, 0.0]

Marshal
Posts: 79061
375
• Number of slices to send:
Optional 'thank-you' note:
You cannot add anything to or remove anything from an array. You can reassign any array element/position, but the size of the array remains unchanged.But that array remains a 5‑element array until you reassign itRemember array elements have default values, like fields, until they are assigned something else.

Seymour Dollars
Greenhorn
Posts: 2
• Number of slices to send:
Optional 'thank-you' note:

Campbell Ritchie wrote:You cannot add anything to or remove anything from an array. You can reassign any array element/position, but the size of the array remains unchanged.But that array remains a 5‑element array until you reassign itRemember array elements have default values, like fields, until they are assigned something else.

I apologize. I didnt mean to use the word "Add" i meant assign .

Here is my updated code, any help would be appreciated.

Campbell Ritchie
Marshal
Posts: 79061
375
• Number of slices to send:
Optional 'thank-you' note:
Please tell us where the assignment to the array is (line number).

 Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters?