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");
}
}
}
Final Grade Program
Page 1 of 19 Replies - 405 Views - Last Post: 17 May 2012 - 05:53 PM
#1
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.
Replies To: Final Grade Program
#2
Re: Final Grade Program
Posted 16 May 2012 - 09:37 AM
what do you mean you are missing an error statement ?
#3
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
*receiving an error that says im missing a return statement
#4
Re: Final Grade Program
Posted 16 May 2012 - 09:41 AM
Change
to a void, because it doesn't return anything.
double markGrades()
to a void, because it doesn't return anything.
This post has been edited by MangoTux: 16 May 2012 - 09:47 AM
#5
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()
#6
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,
#7
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
#8
Re: Final Grade Program
Posted 16 May 2012 - 09:46 AM
mrhemphill, 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
#9
Re: Final Grade Program
Posted 16 May 2012 - 09:46 AM
thank you crunch ! that was the issue.
#10
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.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote






|