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 < scores.length; 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 < scores.length; 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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions

Question

Solve using the appropriate method. (y + 1)y'= yte t2 , y(0) = 1

Answered: 1 week ago

Question

What is the purpose of an executive summary?

Answered: 1 week ago

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago