1 Replies - 159 Views - Last Post: 08 November 2017 - 06:12 PM Rate Topic: -----

#1 wecart2  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-November 17

Need help! program keeps giving me .class expected error and ; exp

Posted 08 November 2017 - 05:56 PM

// Fig. 4.17: Studentgrade1.java
// Student grade takes values from multible quizes and tests and gives a letter grade.
import java.util.Scanner;

public class Studentgrade1 {

String studentName;

private int percentGrade;
private int quiz1;
private int quiz2;
private int midTermTest;
private int finalTest;
private char finalLetterGrade;

Scanner stdin = new Scanner( System.in );

public static void main(String[] args) {
Scanner stdin = new Scanner( System.in );
Studentgrade1 studentdata = new Studentgrade1();
Studentgrade1 studentgrade = new Studentgrade1();
studentdata.readStudentData();


studentdata.getStudentGrade();
System.out.println("The percent grade is " + studentdata.getStudentGrade());

studentdata.findFinalLetterGrade(percentGrade);
System.out.println("The final letter grade is" + studentdata.findFinalLetterGrade(percentGrade));





}



public void readStudentData (){

System.out.println("What is the students name?");
String studentName = stdin.nextLine();


System.out.println("Enter Quiz 1 score out of 10 points");
quiz1 = stdin.nextInt();
this.quiz1=quiz1;
System.out.println("Enter Quiz 2 score out of 10 points");
quiz2 = stdin.nextInt();
this.quiz2=quiz2;
System.out.println("Enter Midterm score out of 100 points");
midTermTest = stdin.nextInt();
this.midTermTest=midTermTest;
System.out.println("enter Final test score out of 100 points");
finalTest = stdin.nextInt();
this.finalTest=finalTest;



if (quiz1 <=10){
System.out.println("Quiz1 score:" + quiz1);
}
else{
System.out.println("Sorry, but Quiz 1 score must be between 0 and 10 Please enter a valid Quiz 1 score:");
quiz1 = stdin.nextInt();
}
if (quiz2 <=10){
System.out.println("Quiz2 score:" + quiz2);
}
else {
System.out.println("Sorry, but Quiz 2 score must be between 0 and 10 Please enter a valid Quiz 2 score:");
quiz2 = stdin.nextInt();

}
if (midTermTest <=100){
System.out.println("Midterm score:" + midTermTest);
}
else {
System.out.println("Sorry, but midterm score must be between 0 and 100 Please enter a valid midterm score:");
midTermTest = stdin.nextInt();
}
if (finalTest <= 100){

System.out.println("Finaltest score:" + finalTest);
}
else {
System.out.println("Sorry, but Final test score must be between 0 and 100 Please enter a valid Final score:");
finalTest = stdin.nextInt();

}


}
public int getStudentGrade (){

percentGrade = (int)((double)25 * (quiz1 + quiz2) / 20
+ (double)25 * midTermTest / 100
+ (double)50 * finalTest / 100 + 0.5);

return percentGrade;


}


public char findFinalLetterGrade (int percentGrade){


if ( percentGrade >= 90) {

finalLetterGrade = 'A';
}
else {
if ( percentGrade >= 80) {
finalLetterGrade = 'B'; }
else {
if ( percentGrade >= 70) {
finalLetterGrade = 'C'; }
else {
if ( percentGrade >= 60) {
finalLetterGrade = 'D'; }
else {
finalLetterGrade = 'F';

}
}
}
}
return finalLetterGrade;

}








}

The problem comes up when i try to put percent grade into an object in main. i dont know how to take the percentGrade and apply it to the lettergrade method. thankyou for any help

Is This A Good Question/Topic? 0
  • +

Replies To: Need help! program keeps giving me .class expected error and ; exp

#2 g00se  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3443
  • View blog
  • Posts: 15,600
  • Joined: 20-September 08

Re: Need help! program keeps giving me .class expected error and ; exp

Posted 08 November 2017 - 06:12 PM

Quote

Need help! program keeps giving me .class expected error and ; exp

That is not the case in the code you posted
http://technojeeves....java1/17-errors

Also
Please use code tags as you were asked. andrewsw's Posted Image instructions will show you how to use code-tags. It isn't difficult.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1