Hello all,
I have created a program(gui) that allows a user to input time and minutes in textfields and then calculates the totals and average wages per hour, to generate a report that displays in a text area. The program works but instead of just calculating the totals, it calculates the totals after each entry, when all I need is just a total of all entries.
The portion of the code where I believe the problem is below:
This is my first time using Java and my first time programming, so any help would be greatly appreciated.
private void runreportButtonActionPerformed(java.awt.event.Acti onEvent evt) {
// Calculates total minutes of tutoring provided, average wages earned per hour, total earned to date, and determines if average wage per hour is below, average, or above minimum wageTODO add your handling code here:
int columns = 2;
int rows = earnings.length;
double totalTime = 0.00;
double totalPayment = 0.00;
double averageWages =0.00;
double minWage =7.00;
DecimalFormat df = new DecimalFormat("#.##");
String report="";
//add total minutes tutoring and display in text area
for (int j=0;j<columns;j++){
//add total earnings and display in text area
for(int i=0;i<rows;i++){
report+= earnings[i][j];
if (j==0){
totalTime+= earnings[i][j];
}else if(j==1){
totalPayment+= earnings[i][j];
report="\n";
//Displays in text area
jTextArea1.append("Total Earnings = $ " +totalPayment+ "\n");
}
//Displays in text area
jTextArea1.append("\n\n");
jTextArea1.append ("Report of your wages to Date\n\n");
jTextArea1.append ("\n");
jTextArea1.append("Total Minutes Spent Tutoring = " +totalTime + "\n");
//calculates average per hour wage
if (earnings.length>0){
averageWages = totalPayment/(totalTime/60);
//Displays in text area
jTextArea1.append("Average Per Hour Wage $ " + averageWages + "\n");
jTextArea1.append("\n\n");
jTextArea1.append("Minimum Wage is currently $6.55");
jTextArea1.append("\n\n");
if(averageWages<minWage){
jTextArea1.append("Your average wages per hour are below Average");
}else if(averageWages>=minWage && averageWages<=minWage * 2.00){
jTextArea1.append("Your average wages per hour are average");
}else if(averageWages > minWage * 2.00){
jTextArea1.append("Your average wages per hour are above Average");
}
}
}
}
}