Я делаю программу, которая просит 5 студентов ввести их имя и gpa, которые будут вычислять самый низкий и самый высокий уровень gpa, а также средний. Я продолжаю получать ошибку «несовместимого типа», хотя я уже инициализировал переменные в конструкторе.Устранение неполадок в строке
System.out.println("Please enter the gpa for the second student");
gpa2 = scan.nextDouble();
System.out.println("Please enter the name for the third student");
student3 = scan.nextLine();
System.out.println("Please enter the gpa for the third student");
gpa3 = scan.nextDouble();
System.out.println("Please enter the name for the fourth student");
student4 = scan.nextLine();
System.out.println("Please enter the gpa for the fourth student");
gpa4 = scan.nextDouble();
System.out.println("Please enter the name for the last student");
student5 = scan.nextLine();
System.out.println("Please enter the gpa for the last student");
gpa5 = scan.nextDouble();
//use scanner to get the gpa
System.out.println("Student Name /" + " Student GPA");
System.out.println("----------------------------);
System.out.println(student1 +" / "+ gpa1);
System.out.println(student2 +" / "+ gpa2);
System.out.println(student3 +" / "+ gpa3);
System.out.println(student4 +" / "+ gpa4);
System.out.println(student5 +" / "+ gpa5);
/**
* Creates objScore object and passas in student parameters to class StudentScore...name and GPA scores
*/
StudentScore objScore = new StudentScore(student1, gpa1, student2, gpa2, student3, gpa3, student4, gpa4, student5, gpa5);
1 error found:
File: C:\Users\Mikey Espinal\OneDrive\Documents\StudentScoreTester.java [line: 46]
Error: incompatible types: double cannot be converted to java.lang.String
Я собираюсь догадка на код, который вы не разделял и предполагают, что есть ошибка в строке 4 –
Как выглядит ваш конструктор StudentScore? –
Пожалуйста, поставьте исходный код непосредственно в сообщении с помощью кнопки «{}» или окружения, подобной этому исходному коду '' – andrewdleach