
I am trying to make a program that uses a main class and a separate class with one public method and one private method. The main method in the main class asks the user for 2 strings and a set of numbers for an array. This array is then sorted in descending numerical order. It then initiates the public method in the second class to print a report to the console. The private method of the second class determines the ,average and mean values of the array and returns that as another array. My code is pasted below. "_" is an underscore
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.*; import java.util.*; import java.text.*;
package Lab09SB;
/** * * @author ConfibulatoryMadness */ public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int MainM = 1;
while(MainM==1){
Scanner scanner = new Scanner(System.in);
System.out.print("Please enter the student's first name - "); //Prompts user to enter name
String studentFirst_Name = scanner.nextLine();
System.out.print("Please enter the student's last name - ");
String studentLast_Name = scanner.nextLine();
System.out.printf("\nHow many grades will you be entering for %s %s- ", studentFirst_Name, studentLast_Name); //asks user how many grades
short numOfGrades = scanner.nextShort();
short[] grades = new short[numOfGrades];
System.out.println("\nPlease enter the grades one at a time, pressing enter after each value.\n");
for(int i = 0; i< numOfGrades; i++)
{
grades[i] = scanner.nextShort(); //Allows user to input grades
java.util.Arrays.sort(grades); //sorts the array
}
Student student1= new Student(studentFirst_Name,studentLast_Name, grades);
student1.ConsoleOut();
System.out.println("Do you wish to continue ( Yes / No ) -");
String Continue = scanner.nextLine();
Continue.toLowerCase();
if(Continue == "no"){
MainM++;
}else if (Continue == "yes"){
MainM=1;
}
}
}
}
class Student {
float [] grades;
String studentFirst_Name;
String studentLast_Name;
private float [] GradeStatistics(){
float sum = 0f;
for(int i = 0; i<grades.length; i++)
{
sum += grades[i]; //gets sum of Array
}
float average = sum/grades.length; //finds the average
float[] studentReport = {average, grades[0], grades[grades.length - 1]}; //get lowest value in sorted array //gets max value in sorted array
return studentReport;
}
public void ConsoleOut(){
System.out.printf("\nThe following is a grade report for %s %s :\nGrades\n"+grades+"\n"+GradeStatistics(),studentFirst_Name,studentLast_Name);
}
}

In your program everything working fine, but replace the Confirmation code as follows, then it works fine.
String Continue = "";
System.out.print("Do you want to Continue (Yes/No) : \n");
while(Continue.equals("")){
Continue = scanner.nextLine();
Continue = Continue.toLowerCase();
if(Continue.equals("no")){
MainM++;
}else if(Continue.equals("yes")){
MainM = 1;
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.