Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Introduction To Data Structures And Algorithm Analysis Java Edition

Authors: Clifford A. Shaffer

1st Edition

0136609112, 978-0136609117

More Books

Students also viewed these Programming questions

Question

Differentiate the function. f(x) = ln(x 2 + 10)

Answered: 1 week ago

Question

What is chart junk? Why do you think it arises?

Answered: 1 week ago