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]
import java.util.Scanner; public class project { private static int rowSelect; private static int positionRow; private static int rowSize; private static double musicianWeight; int totalWeight; private static Scanner keyboard = new Scanner(System.in); public static void main() { double[][] row ; double average, total,weight; double MAX_ROW_WEIGHT = 0.0; int positionInRow, index, numberOfRows; System.out.println("Welcome to the Band of the Hour"); System.out.println("-------------------------------"); System.out.print("Please enter number of rows : "); numberOfRows = keyboard.nextInt(); row = new double [numberOfRows][]; //Add number of positions for (index = 0; index < row.length; index++) { System.out.print("Please enter number of positions in row " + (char)((int) 'A' + index) + ":"); rowSize = keyboard.nextInt(); row [index] = new double [rowSize]; for(positionInRow = 0; positionInRow < row.length; positionInRow++){ row[index][positionInRow]= 0.0; } displayMenu (row); } } //function for displaying menu to the user private static void displayMenu (double[][] row) { char command; do { System.out.println("(A)dd, (R)emove, (P)rint, e(X)it (Not case sensitive): "); command = keyboard.nextLine().charAt(0); switch (command){ case 'A'|'a': addMusician(row); break; case 'R'|'r': removeMusician(row); break; case 'P'|'p': printBandstand(row); break; case 'X'|'x': System.out.println("Thank you for using my program!"); break; default: System.out.println("ERROR: Invalid option, enter an acceptable value :"); } } while (command != 'X'); } private static void addMusician(double[][] row){ double MAX_WEIGHT = 200.0; double MIN_WEIGHT = 45.0; System.out.println("Please select Row to ADD musician: "); rowSelect = keyboard. nextInt(); if (rowSelect > 10 | rowSelect < 0) System.out.println("Error, please enter a valid row "); else System.out.println("Please enter position in row to ADD musician: "); positionRow = keyboard.nextInt(); //I want to display the amount of positions in the row next to this question (1-?) // it would be "Active" displaying whatever the user inputed as the total number of spaces in this row. //This will help the user know how many positions are in the row, //instead of selecting something that doesnt work if (positionRow < rowSize){ System.out.println("Please enter weight of musician: "); musicianWeight = keyboard.nextDouble(); //I want to check if musicianWeight is below and above the min and max //weight allowed, before adding it //add user weight to the postion System.out.println("*****Musician Added*****"); } else System.out.println("Invalid position"); //I also want to make sure that the position in the array is empty (0.0). //I dont want to overwrite a value,just add to only blank spaces. // I want to keep a running total of the current weight in the numeric portion of the 2nd array, //I want to display that total alongside "Please enter weight of musician (currentweight in the array)" //This would be important so the user knows how much more they can add before reachhing the limit } //method for removing musician from a position private static void removeMusician(double[][] row){ System.out.println("Please select Row to REMOVE musician: "); rowSelect = keyboard. nextInt(); if (rowSelect > 10 | rowSelect < 0){ System.out.println("Error, please enter a valid row "); } else //select row to begin removing musician System.out.println("Please enter POSITION in row to REMOVE musician: "); positionRow = keyboard.nextInt(); if (positionRow <= rowSize){ //must make the array position 0.0 double[rowSelect][positionRow] = 0.0; //getting error to remname the local variable. // I need all of this to keep looping until a valid position is entered. } else { System.out.println(" Error, please enter a valid position in row!"); } } //method for printing the entire bandstand private static void printBandstand(double[][] row){ System.out.println("Band Chart"); System.out.println("------------"); //println all code needed to output the array //print average + total of the weight in each array position (Average, total) System.out.println("¸.•*¨*•♫♪¸¸.•*¨*•♫♪¸¸.•*¨*•♫♪¸¸.•*¨*•♫♪¸¸¸.•*¨*•♫♪"); } //reaching end of file while parsing error, just saying...