I have been working on this for days!! I dont want to allow negative numbers in my program. I have changed it so many times I cant stand to look at it anymore. I greatly appreciate any help even just an example of what I need to do. I will be forever grateful!!!! THANKS!
int cols = 2;
int rows = tutoringSessions[0].length;
// Initialize a new array with one more row than the existing array
double[][] newTutoringSessions = new double[2][rows + 1];
// Add data inputted into new array
try{
newTutoringSessions[0][rows] = Double.parseDouble(timeSpentTextbox.getText());
newTutoringSessions[1][rows] = Double.parseDouble(earningsTextbox.getText());
if(earningsTextbox.getText().isEmpty());
if(timeSpentTextbox.getText().isEmpty());
if(earningsTextbox.getText().compareTo("0") == '0' );
if(timeSpentTextbox.getText().contentEquals("0"));
}catch(Exception e){
System.out.println("Please Enter A number");
JOptionPane.showMessageDialog(null,"Text Fields cannot be empty, please start over");
}
// Copy old tutoringSessions data into new array
if (rows > 0) {
for (int i = 0; i < cols; i++)
{
for (int j = 0; j < rows; j++) {
newTutoringSessions[i][j] = tutoringSessions[i][j];
}
}
}
// Set tutoringSessions to new array
tutoringSessions = newTutoringSessions;
// Clear text fields
timeSpentTextbox.setText("");
earningsTextbox.setText("");
}
private void runReportsMouseClicked(java.awt.event.MouseEvent evt) {
// TODO add your handling code here:
int cols = 2;
int rows = tutoringSessions[0].length;
double timeSpentTotal = 0.00;
double earningsTotal = 0.00;
double averageWage = 0.00;
double minimumWage = 6.55;
String report = new String();
report += "****************************************************\n\n";
report += "Raw Tutoring Earnings Data\n\n";
report += "\n";
report += "Minutes Earnings\n";
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
report += Double.toString(tutoringSessions[j][i]);
report += " ";
if (i == 0) {
timeSpentTotal += tutoringSessions[j][i];
} else if (i == 1) {
earningsTotal += tutoringSessions[j][i];
}
}
report += "\n";
}
if (tutoringSessions[0].length > 0) {
averageWage = earningsTotal / tutoringSessions[0].length;
}
report += "****************************************************\n\n";
report += "Report of your wages to Date:\n";
report += "____________________________\n\n";
report += "Total Minutes Spent Tutoring = " + Double.toString(timeSpentTotal) + "\n";
report += "Total Earnings = $" + Double.toString(earningsTotal) + "\n";
report += "Average Per Hour Wage = $" + Double.toString(averageWage) + "\n";
report += "Minimum Wage is currently = $" + Double.toString(minimumWage) + "\n";
report += "Your average wages per hour are ";
if (averageWage < minimumWage) {
report += "Below Average";
} else if (averageWage >= minimumWage && averageWage <= minimumWage * 2.00) {
report += "Average";
} else if (averageWage > minimumWage * 2.00) {
report += "Above Average";
}
itemizedReportTextarea.setText(report);