9 Replies - 623 Views - Last Post: 17 May 2012 - 05:53 PM Rate Topic: -----

#1 mrhemphill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 16-May 12

Final Grade Program

Posted 16 May 2012 - 09:33 AM

i have an assigment in my course and the objective is to create a program that detertimes a percent and letter grade with test , midterm and exam marks. my problem is that im receiving an error that says i am missing an error statement, but i cannot find where? any help is appreciated.

import java.io.*;
public class GradesTester
{
	// start the program
	public static void main(String[] args) throws IOException
	{
	Grades student1 = new Grades("Adam Lizote", 85.5, 69, 70);
	student1.markGrades();
	Grades student2 = new Grades("Derik Shasse", 57.9, 80, 85);
	student2.markGrades();
	Grades student3 = new Grades("Asha Barnabey", 93, 83, 89);
	student3.markGrades();
	Grades student4 = new Grades("Brad Bouchee", 45.67, 60, 87.56);
	student4.markGrades();
	// applies the markGrades() method
	}
} 

class Grades
{
	//variables 
	String name;
	double test;
	double midterm;
	double exam;
	double mark;
	double grade;
	
	//initialize variables
	public Grades(String nameStudent, double testMark, double midtermMark, double examFinal)
	{
		name = nameStudent;
		test = testMark;
		midterm = midtermMark;
		exam = examFinal;
	}
	//method
	double markGrades()
	{ 
	mark = ((exam * 0.25) + (midterm * 0.25) + (test*0.5) );
	if (mark >= 90)
	{
		System.out.println(name + "'s Final Grade: " + mark + " or a letter grade of: A");
	}
	else if (mark >= 80 && mark < 90)
	{
		System.out.println(name +"'s Final Grade: " + mark + " or a letter grade of: B");
	}
	else if (mark >= 70 && mark < 80)
	{
		System.out.println(name + "'s Final Grade: " + mark + " or a letter grade of: C");
	}
	else if (mark >= 60 && mark < 70)
	{
		System.out.println(name + "'s Final Grade: " + mark + " or a letter grade of: D");
	}
	else if (mark < 60)
	{
		System.out.println(names + "'s Final Grade: " + mark + " or a letter grade of: F");
	}
	
	}
}




Is This A Good Question/Topic? 0
  • +

Replies To: Final Grade Program

#2 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: Final Grade Program

Posted 16 May 2012 - 09:37 AM

what do you mean you are missing an error statement ?
Was This Post Helpful? 0
  • +
  • -

#3 mrhemphill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 16-May 12

Re: Final Grade Program

Posted 16 May 2012 - 09:41 AM

*receiving an error that says im missing a return statement

*receiving an error that says im missing a return statement
Was This Post Helpful? 0
  • +
  • -

#4 MangoTux  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 58
  • Joined: 06-April 11

Re: Final Grade Program

Posted 16 May 2012 - 09:41 AM

Change
double markGrades()


to a void, because it doesn't return anything.

This post has been edited by MangoTux: 16 May 2012 - 09:47 AM

Was This Post Helpful? 1
  • +
  • -

#5 Crunch  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 139
  • View blog
  • Posts: 1,222
  • Joined: 28-July 09

Re: Final Grade Program

Posted 16 May 2012 - 09:43 AM

you should change double to void if you are not expecting a value from it.

void markGrades()

Was This Post Helpful? 2
  • +
  • -

#6 mrhemphill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 16-May 12

Re: Final Grade Program

Posted 16 May 2012 - 09:44 AM

taking that away doesnt effect it, i think the "missing return" error i get is related to my method? we just learned methods and such this unit,
Was This Post Helpful? 0
  • +
  • -

#7 calumdt  Icon User is offline

  • New D.I.C Head

Reputation: 5
  • View blog
  • Posts: 20
  • Joined: 28-January 11

Re: Final Grade Program

Posted 16 May 2012 - 09:44 AM

change your return type from double to void in line 38 and names to name in line 59
Was This Post Helpful? 0
  • +
  • -

#8 IamTw_  Icon User is offline

  • D.I.C Head

Reputation: 32
  • View blog
  • Posts: 238
  • Joined: 25-February 11

Re: Final Grade Program

Posted 16 May 2012 - 09:46 AM

View Postmrhemphill, on 16 May 2012 - 09:33 AM, said:

my problem is that im receiving an error that says i am missing an error statement, but i cannot find where? any help is appreciated.

You have created a method which expects a double as return type.
//method
	double markGrades()
	{  
        }


If you don't want it to return anything, make it void
Was This Post Helpful? 2
  • +
  • -

#9 mrhemphill  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 33
  • Joined: 16-May 12

Re: Final Grade Program

Posted 16 May 2012 - 09:46 AM

thank you crunch ! that was the issue.
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8342
  • View blog
  • Posts: 31,880
  • Joined: 06-March 08

Re: Final Grade Program

Posted 17 May 2012 - 05:53 PM

And next time, when you have a compilation error, post the exact error displayed by the compiler that will save time.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1