Question: netbeans why wont my code disinclude the smallest value public class example { private int[] labScores; private int[] examScores; private String firstname; private String lastname;

netbeans why wont my code disinclude the smallest value

public class example {

private int[] labScores;

private int[] examScores;

private String firstname;

private String lastname;

public final int Lab = 3;

public void setFirstName(String myFirstName) {

firstname = myFirstName;

}

public String toString() {

return \"Student \" + firstname + \" \" + lastname + \"...\";

}

public Student() {

}

public Student(String FirstName, String LastName, int[] labScores,

int[] examScores) {

firstname = FirstName;

lastname = LastName;

labScores = labScores;

examScores = examScores;

}

Student(String firstName, String lastName) {

firstname = firstName;

lastname = lastName;

}

public int[] getLabScores() {

return labScores;

}

public void setLabScores(int[] mylabScores) {

labScores = mylabScores;

}

public int[] getExamScores() {

return examScores;

}

public void setExamScores(int[] myexamScores) {

examScores = myexamScores;

}

private int calculateTotal(int[] scores, boolean isSkipLowestScore) {

int total = 0;

int idxOfLowest = getIndexForLowestScore(scores);

for (int i = 0; i

if (isSkipLowestScore && i== idxOfLowest) {

continue;

}

total += scores[i];

}

return total ;

}

private char determineLetterGrade(double avgScore) {

if (avgScore >= 90) {

return 'A';

}

if (avgScore >= 80) {

return 'B';

}

if (avgScore >= 70) {

return 'C';

}

return 'F';

}

public void reportGradeForLabs() {

System.out.println(\"Lab report \");

double total = calculateTotal(labScores, true);

double avg = total / (double) labScores.length;

char grade = determineLetterGrade(avg);

System.out.println(Arrays.toString(labScores) + \" Total \" + total);

System.out.println(\"Average: \" + avg);

System.out.println(\"Grade: \" + grade);

}

public void reportGradeForExams() {

System.out.println(\"exam report \");

double total = calculateTotal(examScores, false);

double avg = total / (double) examScores.length;

char grade = determineLetterGrade(avg);

System.out.println(Arrays.toString(examScores) + \" Total \" + total);

System.out.println(\"Average: \" + avg);

System.out.println(\"Grade: \" + grade);

}

private int getIndexForLowestScore(int[] scores) {

int idxOfLowest = 0;

for (int i = 0; i

if (scores[idxOfLowest] > scores[i]) {

idxOfLowest = i;

}

}

return idxOfLowest ;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!