Question
I keep getting an error. I asked a question yesterday and it was posted but I get an error What am I doing wrong. Also
I keep getting an error. I asked a question yesterday and it was posted but I get an error What am I doing wrong. Also I am to drop the lowest score when I determine the grade. This one counts all scores. thanks Here is my program and my issues. +++++++++++++++++++++++++++ public class MyClass { private String [] names; //names of the studi (sorry a fall back on a former life) private char [] grades; // self explanatory private int [][] scores; //one for the gipper //To my class and to initialize the new vaiables public MyClass() { names=new String[5]; grades=new char[5]; scores=new int[5][4]; } // to return names public String[] getNames() { return names; } // to return the grade... but not stats public char[] getGrades() { return grades; } // to return the scores public int[][] getScores() { return scores; } //To display details of 5 students public void displayDetails() { int avg,sum; System.out.println(" ************ Details Entered Are ************"); for(int i=0;i<5;i++){ avg=0; sum=0; for(int j=0;j<4;j++){ sum+=scores[i][j]; } //sum contains total of 4 scores //Calculating average using sum avg=sum/4; System.out.println("Student Name:"+names[i]+" Average Score:"+avg+" Grade Scored:"+grades[i]); } } public String getStudentByName(String name) { //As specified,a method to return details of a given Student for (int i = 0; i < names.length; i++) { if(names[i].equalsIgnoreCase(name)){ //If the Student name matches in the stored names float avg=0.0f; for (int j = 0; j < 4; j++) { avg+=scores[i][j]; } avg=avg/4; //Calculated the average return "Student Name:"+names[i]+" Average Score:"+avg+" Grade:"+grades[i]; //It will return the details as the student was found } } return "Student not available"; //If Student is not found in the Stored array } } +++++++++++++++++++++++++++ package util; import java.util.Scanner; // for scanner import still not worthy import java.util.Collections; // wahoo a new util i found that did my trick public class ClassDemo { // i had have not idea what i should call this public static void main(String[] args) { // for the scanner class Scanner sc = new Scanner(System.in); MyClass c1 = new MyClass(); //For local purpose double avg,sum; //To get instance variables of MyClass object String [] names; char [] grades; int [][] scores; grades=c1.getGrades(); names=c1.getNames(); scores=c1.getScores(); //To get details from User for 5 Students: for(int i=0;i<5;i++){ System.out.println("Enter details of Student "+(i+1)+":-"); System.out.println("Enter name:"); names[i]=sc.next(); avg = 0; sum=0; int low = 100; int score=0; for(int j=0;j<4;j++){ System.out.println("Enter Score:"+(j+1)); score=sc.nextInt(); //Validating Score reallly had an issue with this not sure why if(score <0 || score>100) { System.out.println("Invalid Score try again..."); j--; //Setting j back by 1 as this was wrong entry - found out this was a big issue... dumb! continue; } else { if(score=90 && avg<=100){ grades[i]='A'; }else if(avg>=80 && avg<=89){ grades[i]='B'; }else if(avg>=70 && avg<=79){ grades[i]='C'; }else if(avg>=60 && avg<=69){ grades[i]='D'; }else if(avg>=0 && avg<=59){ grades[i]='F'; } } } public static double calculateAvg(int inputs[], int lowNum) { double sum = 0; double avg = 0; int i = 0; // Calcuates the average of the array list with the lowest numbers dropped for (i = 0; i < inputs.length; i++) { if (inputs[i] > lowNum) { sum = sum + inputs[i]; } } avg = (sum / inputs.length); System.out.println(avg); return avg; } } +++++++++++++++++++++++++++ ClassDemo.java:17: error: cannot find symbol MyClass c1 = new MyClass(); ^ symbol: class MyClass location: class ClassDemo ClassDemo.java:17: error: cannot find symbol MyClass c1 = new MyClass(); ^ symbol: class MyClass location: class ClassDemo 2 errors ----jGRASP wedge2: exit code for process is 1. ----jGRASP: operation complete. My stupis errors they are in the same folder. And i tried to change wording but that didnt work, so I am at a loss. thanks ahead of time
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started