• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding and removing from an array while conditions are met.  RSS feed

 
Seymour Dollars
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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]


 
Campbell Ritchie
Marshal
Posts: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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: 56546
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell us where the assignment to the array is (line number).
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!