• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Grading Program--Need help, please!!!

 
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey guys! Can you help me out here? I'm trying to write a program that has 2 quizzes, each graded on the basis of 10 points.
There is 1 midterm grade and 1 final exam, each graded on the basis of 100 points.
The final exam counts for 50% of the grade, the midterm counts for25%. amd tje 2 quizzes together count for a total of 25%. I somehow need to normalize my quiz scores, which I don't know how to do. And I do believe the grades have to be converted to percentages before they can be averaged...which I surely don't know how to do.

And then I have to define a class for the student records, which had instances variables for the quizzes, midterm, and overall numeric score for the course, and final letter grade.

And good grief, it needs a ton more stuff. I am lost....any ideas..??
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Something like this maybe

a Student class
private fields studentName,studentID,midTermScore, finalExamScore, grade.
the constructor to set the name and id
2 public setter methods setMidTermScore(),setFinalExamScore()
1 public getter method getGrade, which includes a call to calculateGrade()
1 private method calculateGrade()

create the student, run the quiz/s, pass the score/s to the student object,
get the grade.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Rose Evans:
...I do believe the grades have to be converted to percentages before they can be averaged...which I surely don't know how to do...


Well, the percentage is the number of points earned multiplied by 100 divided by the number of points possible.

As for the Java... First you need to get a clear idea of what you're trying to accomplish. It sounds like you'll be defining a class -- something like "StudentRecord." These objects will have certain things, like scores; and they will do certain things, like calculate percentages and return grades.

So, first you need to be a little more clear on what you want a StudentRecord to do. That is, what methods you want to define for the class.

Next, you'll want to describe (in English) the steps that each method will take. Something like: "This method should take the first quiz score and add it to... or multiply it by... or whatever... Then take that result and add it to... or multiply it by..."

That should help you get a start on the code. At that point, if you run into trouble on a particular step, post the code you have and tell us exactly what's giving you a problem.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael and Mark,

Thank you!! You two guys sound like you really know java! You must have taken it a long time, or worked with it. I am having the hardest time with Java and C++. I have SO many programs to write at once until they begin to bog my mind really fast. Thank you so much for your help!!! It is greatly appreciated!!
 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hope i'm not to late, but i'm gonna give you this advice...

don't try and write the whole thing before you compile and test. you'll get a million compile errors that will just freak you out, and even if you fix all of them, you'll get a program that doesn't even come CLOSE to working right.

I'm not doubting your ability, i'm just saying that this is how it happens for everyone.

Do all the planning like Michael and Marc suggest, before writing a single line of code.

Then, when you do start writing, write as LITTLE code as possible before you test. and test it a LOT. once you're SURE that is working right, write another few lines of code (one of the sherrifs here will tell you to try writing only 1 line at a time before compiling/testing, but i think that's a little extreme).

Note that you may have to write a little 'fake' code to get the 'real' code to work. If you decide to write the averaging method first, you may write some code that FORCES the test scores to be certain values. That way when it doesn't work, you know to look at the averaging part, and not the getting the values, the storing the values, the passing the values, the printing of hte values, etc.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Fred. You have great advice! I'll see what I can do.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Perhaps you can start by making up an example set of grades for a single student and calculating the student's grade by hand. This should give you some insight into how to write a program to do it.

Layne
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Layne,

Thank you. Ill surely try this approach!!
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And read Accellerated C++ (Koenig and Moo, ISBN 020170353X) in which they create a student grading program as the example throughout the book.

Not Java but the concepts are the same.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK guys...I'm starting small. This is what I have so far...Take a peak at my code and see if you can give me some advice...
_______________________________________________________________________

public class gradingProgram
{
public static void main(String[] args)
{

int quiz1;
int quiz2;
int midtermExam = 0;
int finalExam = 0;
int finalScore = 0;
int grade = 0;
String name;

System.out.println("Students calculated final scores");
System.out.println("and letter grades. ");
System.out.println("Please enter your name. ");
name = SavitchIn.readLine();

System.out.println("Please enter your first quiz grade. ");
quiz1 = SavitchIn.readLineInt();
System.out.println("Please enter your second quiz grade. ");
quiz2 = SavitchIn.readLineInt();
System.out.println("Please enter your midterm exam. ");
midtermExam = SavitchIn.readLineInt();
System.out.println("Please enter your final exam score. ");
finalExam = SavitchIn.readLineInt();

if (finalScore >= 90)
grade = 'A';

if (finalScore >= 80)
grade = 'B';

if (finalScore >= 70)
grade = 'C';

else if (finalScore >= 60)
grade = 'F';


System.out.println("Student name: " + name);
System.out.println("First quiz score: " + quiz1);
System.out.println("Second quiz score: " + quiz2);
System.out.println("Midterm Exam score: " + midtermExam);
System.out.println("Final Exam score: " + finalExam);







}
}
_______________________________________________________________________

There are two quizzes, each graded on the basis of 10 points.
There is one midterm exam, and one final exam, each graded on the basis of 100 points.
The final exam counts for 50 % of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores, They should be coverted to percentages before they are averaged in.)

I need to define a class for the student record. The class should have instance variables for the quizzes, miidterm, final, overall numeric score for the course, and final letter grade. The overall numeric score is a number in the range of 0 to 100, which represents the weighted average of the students work. The class should have input and output methods. the input method should not ask for the final numeric grade, nor should it ask for the final letter grade. The class should have methods to compute the overall numeric grade and final letter grade. Thes last two methods will be void methods that set the appropriate instance variables.
________________________________________________________________________

I'd great appreciate any advice.
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This looks like a good start. Have you compiled/run it? i'm assuming SavitchIn is something your teacher provided to get the input data.

I am assuming the input will all be percentages? it's not entirely clear from the directions, but it shouldn't be hard to convert it if it's not.

the hard part now is calculating that final score...

Let me give you a simpler example, and see if you can extrapolate the method to your situation...

Say i had one test worth 75 points, and one quiz worth 10 points. the test was 85% of the final grade, and the quiz 15%.

now i get the scores of 72 and 6. so they scored 96% and 60% on the test and quiz respectivly.

to figure out their total score, you can do this...

they get 96% of the 85% for the test, or 81.6
they get 60% of the 15% for the quiz, or 9

this totals 90.6. they get an A.

you will do something similar for your 4 scores, but remember that the TWO quizzes total 25%... you can either take EACH quiz worth 12.5%, or treat them as one (with a little hand waving) worth 25%...

hope that helps!!!
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I have ran it and it works perfectly so far. Yes, SavitchIn is a way of getting input from the users. Im thinking that the grades will NOT be entered as percentages, it tells you near the end to make sure that you convert them to percentages.
Thank you so much for your help. I'll go work on it and see what I can do now.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm still stuck...this is all I have so far...
_____________________________________________________________________

public class gradingProgram
{
public static void main(String[] args)
{

int quiz1 = 0;
int quiz2 = 0;
int midtermExam = 0;
int finalExam = 0;
int finalScore = 0;
char grade;
String name;
int totalQuiz;



System.out.println("Students calculated final scores");
System.out.println("and letter grades. ");
System.out.println("Please enter your name. ");
name = SavitchIn.readLine();

System.out.println("Please enter your first quiz grade. ");
quiz1 = SavitchIn.readLineInt();
System.out.println("Please enter your second quiz grade. ");
quiz2 = SavitchIn.readLineInt();
System.out.println("Please enter your midterm exam. ");
midtermExam = SavitchIn.readLineInt();
System.out.println("Please enter your final exam score. ");
finalExam = SavitchIn.readLineInt();


totalQuiz = ((quiz1 + quiz2) / 2);

if (finalScore >= 90)
grade = 'A';
//System.out.println("Your letter grade is " + grade);

else if (finalScore >= 80)
grade = 'B';

else if (finalScore >= 70)
grade = 'C';

else if (finalScore >= 60)
grade = 'F';


System.out.println("Student name: " + name);
System.out.println("First quiz score: " + quiz1);
System.out.println("Second quiz score: " + quiz2);
System.out.println("Midterm Exam score: " + midtermExam);
System.out.println("Final Exam score: " + finalExam);
System.out.println("Total quiz score is " + totalQuiz);







}
}
____________________________________________________________________
What I have so far works perfectly.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are two quizzes, each graded on the basis of 10 points.
There is one midterm exam, and one final exam, each graded on the basis of 100 points.
The final exam counts for 50 % of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores, They should be coverted to percentages before they are averaged in.)

I need to define a class for the student record. The class should have instance variables for the quizzes, miidterm, final, overall numeric score for the course, and final letter grade. The overall numeric score is a number in the range of 0 to 100, which represents the weighted average of the students work. The class should have input and output methods. the input method should not ask for the final numeric grade, nor should it ask for the final letter grade. The class should have methods to compute the overall numeric grade and final letter grade. Thes last two methods will be void methods that set the appropriate instance variables.
_________________________________________________________________________

This is the part I have no idea how to do...
Please any help would be greatly appreciated...
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Rose,

We have a small problem... the specs for this assignment say (now that i've read them) "define a class that... blah blah blah".

what you have is a very procedural-style program, not an OO program. but that's ok, we can still use a LOT of the code you wrote. we're just gonna have to re-think a few things.

A class has two kinds of things in it - things it KNOWS and things it DOES. these are often referred to as member variables and member functions, or methods.

so lets see what you class knows...

"The class should have instance variables for the quizzes, miidterm, final, overall numeric score for the course, and final letter grade."

in your code, you have defined all these variables in the main() method. Theoretically, i want my StudentRecord to be a blueprint that somebody else can take and use to make a gradebook program - they will want to make dozens of StudentRecord objects, but will never call your main() method. we need a place for those variables that exists outside of any specific method, so we'll do just that...


now, somebody can make 12 StudentRecord objects, and each will have it's own copies of that students grades. in your main method, you can now do this:


we now have three objects, each having it's own set of scores. but right now, we can't DO anything - we can't even change the scores... so, we need to teach the class to DO something. Maybe we can teach the class to learn what quiz1 should be...

in the StudentRecord class, i need to make a method that will set the quiz1 score. i'm going to need to tell the object what that score is, and it's probably an integer. so i'd write:


in my main(), after i created the three student records, i could then tell each one to set it's quiz1 score by passing it a score...


note that i could write a method that takes 6 or 7 or any number of input parameters:


or, it might take no parameters, but the object itself can ask for the input when you call a method - you'd use a lot of the code you already wrote

i can then keep writing new functions that describe what the object can do...

you will need some methods for inputting the data (similar to what i have above), and outputting (something like a printInfo() method).

you will probably also write a method that will compute the letter grade and the final numeric grade (two separate methods, from the specs). they won't take any input, but they could validate all the quiz/test scores are entered, and it would calculate the scores and set the variables...

I know it sounds like a lot, but if you take it one step at a time, it's really not too bad.

when all is said and done, your main() method should be pretty short... possibly not much more than

StudentRecord student1 = new StudentRecord();
student1.setAllScores(); //have the object iteself ask for input data
student1.calcLetterGrade();
student1.calcFinalNumGrade();
student1.printScores();

take it slow, try to do one thing at a time, and build off each previous piece.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fred, YOU are good! How'd you learn to do something like that? It sounds like you could write the program with ease. My hat is off to you!
I'll see what I can do with my program.
Thanks so much for your help!!
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, to answer your probably rhetorical question, i first learned Pascal about 10 years ago. Then i learned C and visial basic. then i did C++. then i learned java. been programming professionally for 5+ years (which is not very long compared to some of the experts here).

I remember struggling with a lot of this stuff too when i was first learning about Object Oritented programming. i always thought very procedurally - i still do. but over time it gets easier.

keep asking questions - that's what this is all about!
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fred,

Well looks like you've done very well for yourself. You seem to know programming with ease. I hope I can be like that one day. Tell me, now as you work for a company programming, (by the way which language are you programming in at your job?), do you have to write code blindly, I mean, do you have to sit down after your boss or whoever gives you a project and just code away blindly? Or do you have sample programs you go by, or do you maybe copy and paste a lot of existing codes and modify them to make a new project?
I am so curious about that! My C++ and Java teacher (which is the same teacher for both courses) seems to think we should be able to sit down and write a huge program out of our heads. I have a friend who programs in an old language, COBOL, and she says they rarely write programs out of their head, she says they do a lot of copy and pasting, but occassionally write something from scratch.

I've taken QBasic, pretty easy language, although, I only had one semester of it, and I had one semester of COBOL. I took two semesters of Visual Basic.NET, which I totally love. Making those GUI'S are fun!!! We didn't always code out of our heads in that class either. We used examples in the book, and in the first semester of it, all we had to do was totally COPY code from the book onto our program to get the feel of what the code was doing to the program.

I like java, it's fun, but my teacher is new to teaching it, and I really think she thinks we should know too much. She goes really fast, and jumps from one topic to another and back again before anyone can grasp the idea of the first concept. I think that is why I am struggling so much trying to write just a simple program as the one I've posted. I need examples to go by and things like that. I'd like to know from ANY programmer how exactly the real world does programming. I'd appreciate any information you could tell me. Thanks so much for your help!! It is great appreciated.

 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been programming "in the real world" for less than a year, so I may not be as qualified to answer your question as others, but here goes. Most of the time you will be modifying existing code or extending ready made classes to perform the funtionality you need. For instance the StudentRecord class that Fred is talking about may be already written and you would have to go in and add some code to it or change something in it. I will say that so far in my experience (web applications) more time is spent testing than actually coding.

As for your Grading program, do like Fred is saying and break it into small pieces. Get your StudentRecords class working so it can accept and change grades. After you have that move on to maybe creating a method that converts the point grades into percentages. Once that works write another method that takes the all the percentages and calculates the final grade. All programs and for that matter problems can be broken into small chunks, you tackle one chunk at a time and then move on. Put lots of System.out lines in your code while your writing it to follow along with what's happening, by doing so you can see that your reaching methods and that your passing the correct variables and so on.

Good Luck!
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hmmm... much of what i do is modifying other code. I do a lot of maintenance code (the end user finds a bug, reports it to us, and then i fix it). But when i develop new features, there's a variety of techniques.

It's a lot like building something out of Legos. there's a large variety of pieces that somebody else has made, and i have to figure out how to connect them together to make my final project.

But sometimes, the block/object doesn't do exactly what i want. OO programming lets me EXTEND a class file. This lets me a) add new functionality to the block without changing how the rest of it works, and b) lets me make a minor (or even a major) tweak to what the class already does, but again, keeps the old version around for everybody else.

One of the goals of OOP is to re-write as little code as possible, and to hopefully NEVER cut-n-paste large hunks into multiple files. say you copy a bunch of lines into 30 files. a year goes by, and somebody reports a bug that occurs in that copied code. are you going to remember which 30 files the code was copied into? probably not.

Usually, even when i do have to write an entire program from scratch, we have something i can model my code off of.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You guys...I guess I am dumber than dirt....but this is all I can think of right now...and it has an error when I try to compile it.
Take a peak at it..what do I need to do??
________________________________________________________________________

public class gradingProgram2
{
//public static void main(String[] args)
{

//studentRecord student1 = new studentRecord();
//studentRecord student2 = new studentRecord();
//studentRecord student3 = new studentRecord();


int quiz1 = 0;
int quiz2 = 0;
int midtermExam = 0;
int finalExam = 0;
int finalScore = 0;
char grade;
String name;
int totalQuiz;

public void readInput()
{


System.out.println("Students calculated final scores");
System.out.println("and letter grades. ");
System.out.println("Please enter your name. ");
name = SavitchIn.readLine();

System.out.println("Please enter your first quiz grade. ");
quiz1 = SavitchIn.readLineInt();
System.out.println("Please enter your second quiz grade. ");
quiz2 = SavitchIn.readLineInt();
System.out.println("Please enter your midterm exam. ");
midtermExam = SavitchIn.readLineInt();
System.out.println("Please enter your final exam score. ");
finalExam = SavitchIn.readLineInt();
}



void calculateScore()
{

totalQuiz = ((quiz1 + quiz2) / 2);

if (finalScore >= 90)
grade = 'A';
System.out.println("Your letter grade is " + grade);

else if (finalScore >= 80)
grade = 'B';
System.out.println("Your letter grade is " + grade);

else if (finalScore >= 70)
grade = 'C';
System.out.println("Your letter grade is " + grade);

else if (finalScore >= 60)
grade = 'F';
System.out.println("Your letter grade is " + grade);

}

void writeOutput()
{

System.out.println("Student name: " + name);
System.out.println("First quiz score: " + quiz1);
System.out.println("Second quiz score: " + quiz2);
System.out.println("Midterm Exam score: " + midtermExam);
System.out.println("Final Exam score: " + finalExam);
System.out.println("Total quiz score is " + totalQuiz);


};




}
}
____________________________________________________________________

This is the error message I get...
F:\JavaI\gradingProgram2.java:32: illegal start of expression
public void readInput()
^
I am trying to look in my book and go by examples..but Im not having much luck.....
Please help, if you can.
 
Hentay Duke
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The reason for that specific error is you have an extra bracket just under the commented out main method (also an extra one at the end of program), unfortunately I think you'll find that while deleting the bracket solves this error it reveals others.

Dont know what "SavitchIn" is, guessing it's a class you have for reading input, but my machine can't resolve it.

You need to surround your if and else/if blocks with brackets if they are more than one line.

If indeed SavitchIn is a class you have, then these corrections should at least allow to to compile, if nothings else.
[ November 04, 2004: Message edited by: Hentay Duke ]
 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I dont seem to follow your code.

1) What are the methods doing in your main loop ?
2) the closing braces of writeOutput() function has a semicolon at the end of it.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
rahul V kumar
Basically, it just gets someones name from them, their grades, and outputs everything they put in. It is supposed to do way more than that.
Thats where Im stuck.

Hentay Duke
Yes, SavitchIn.readLine is a way of getting input. It wont run on your machine unless you have the Savitchin file in the same folder as your code you are writing. Ill take a look at what you told me and see what I can do.
Thank so much!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You seem to be heading in the wrong direction.
See if you can follow this
(the work shouldn't be done in main(), and it needs a bucketload of error handling
also, is untested - I don't have your SavitchIn classes - may need a tweak)

 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael Dunn,

You are a genious!!! I tried your code and it works perfectly. I only did one small tweak and boom, it worked!! My hat is off to you!!!
I have GOT to get a hand on this stuff. I really like java, LOVE applets for sure. I just get so mixed up with classes and where to put stuff. I have in my head what I want my program to do, but when it comes to sitting down and actually writing the code, I get all mixed up. I can usually do a small program or something that is just all coded in main.
I'm going to review your code over and over until I understand each and every part of it.

I am amazed at the ease of how you did that program. You must really be good at java.

By the way...I noticed your name...I used to work with a Mike Dunn, where are you from? (If you don't mind me asking)

Thanks again for your help. It is greatly appreciated!!!
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>I used to work with a Mike Dunn, where are you from?

Sydney, Australia
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,

Oh, the Michael Dunn, I worked with lived in South Carolina. I dont think you're the same person.
Thank you again for your help. I really appreciate it!!!
You are very talented!!!
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,

Oops I did something wrong, if I enter 20,32,50,10 as my four grades, I get an A....wonder why? Ha.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"...has 2 quizzes, each graded on the basis of 10 points."

I took this to be quiz1 and quiz2 would each be in the range 0 to 10.
This is one of the (many) areas requiring error-handling.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok guys...duh, on my part again. I am trying to convert the following code to a code that I have commented out, but it doesnt work. What am I doing wrong. I'd appreciate any help! And you all have helped me greatly so far, thank you!
__________________________________________________________________________

Public String toString()
{
return

"\nStudent name: \t\t"+name+"\nFirst quiz score: \t"+quiz1+"\nSecond quiz score: \t"+quiz2+
"\nMidterm Exam score: \t"+midTermExam+"\nFinal Exam score: \t"+finalExam+ "\nFinal score: \t\t"+new
java.text.DecimalFormat("0.00").format(finalScore)+"\nGrade: \t\t\t"+grade; }}

/*
( I have this part commented out. It's a little easier for me to follow
if I code it like this...but I get a ton of errors when I try to do it.

System.out.println("Student's name: " + name);
System.out.println("First quiz score: " + quiz1);
System.out.println("Second quiz score: " + quiz2);
System.out.println("Midterm Exam score: "+ midTermExam);
System.out.println("Final Exam Score: " + finalExam);
System.out.println("Final Score: " + new java.text.DecimalFormat ("0.00").format(finalScore));
System.out.println("Your letter grade is: " + grade);
}
}

*/

Any ideas?

 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,
I'm assuming the two quizzes together count for 25% of the final grade...

There are two quizzes, each graded on the basis of 10 points.
There is one midterm exam, and one final exam, each graded on the basis of 100 points.
The final exam counts for 50 % of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores, They should be coverted to percentages before they are averaged in.)

What should I do?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're heading off in the wrong direction again.

By including specific System.out.println() in the class object, you limit its use
e.g you cannot use the StudentRecord class in a GUI application, without modifying the code

see if it's easier to follow, this way
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
>I'm assuming the two quizzes together count for 25% of the final grade...

my assumption:
25 points allocated for results of (quiz1 and quiz2)
e.g. full marks, 10 + 10 = 20 = 25 points
20 * 1.25 = 25
((quiz1+quiz2)*1.25)
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael...the last output code you sent me I can understand a lot better thank you!!!

This is my output when I enter some grades...

________________________________________________________________

Please enter your name: Rose

Please enter your first quiz grade: 10

Please enter your second quiz grade: 60

Please enter your midterm exam: 60

Please enter your final exam score: 65

Student name: Rose
First quiz score: 10
Second quiz score: 60
Midterm Exam score: 60
Final Exam score: 65
Final score: 135.00
Grade: A
____________________________________________________

I'm not sure why it's giving me an A if I enter those grades...any idea??
 
fred rosenberger
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aren't the quiz scores supposed to be from 0-10? if you enter a quiz score of 60, that's saying the student got 600% on the quiz...

if you wanted, you could put some error checking in your code - i.e. after you get all the values, test them to make sure they're in the appropriate range.
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All I can tell is together they are worth 25% of the grade...
__________________________________________________________________

finalScore = ((quiz1+quiz2) * 1.25) + (midTermExam * .25) + (finalExam * .50);
__________________________________________________________________
Maybe the finalScore needs to equal ((quiz1+quiz2) * .25 instead of 1.25. Whatcha think?
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys...take a look at this for me...

There are two quizzes, each graded on the basis of 10 points.
There is one midterm exam, and one final exam, each graded on the basis of 100 points.
The final exam counts for 50 % of the grade, the midterm counts for 25%, and the two quizzes together count for a total of 25%. (Do not forget to normalize the quiz scores, They should be coverted to percentages before they are averaged in.)
____________________________________________________________________

Say I enter a 95 and a 75 for the two quizzes.
I enter a 96 for the Midterm, and
I enter a 80 for the final exam....

This is my output from the DOS screen....

Please enter your name: Rose
Please enter your first quiz grade: 95
Please enter your second quiz grade: 75
Please enter your midterm exam: 96
Please enter your final exam score: 80
Student name: Rose
First quiz score: 95
Second quiz score: 75
Midterm Exam score: 96
Final Exam score: 80
Final score: 106.50 (Does this look right?)
Grade: A
___________________________________________

I am so clueless, and I get confused when the top part says the two quizzes are graded on a basis of 10 points each, but the two quizzes together count as 25% of the grade...
Any ideas??
 
Rose Evans
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fred,

Duh on my part, I just reread your post to me, and now I understand what you are saying about the 10 points part. I wonder where my brain is at times. Ha. Thanks for your help.
 
Hentay Duke
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"You are a genious!!! I tried your code and it works perfectly. I only did one small tweak and boom, it worked!! My hat is off to you!!!
I have GOT to get a hand on this stuff. I really like java, LOVE applets for sure. "

Rose, glad you're making some progress, but it's gonna take you a lot longer to "get a hand on this stuff" if you don't take it one step at a time and understand everything you're doing. Michael was very nice to post the code for you, but probably didn't help you much in the long run. The only way to really grasp this stuff is to work it out yourself with a few pointers here and there. Doing one small tweak to someone elses code doesn't help you learn much. Just my opinion and only trying to help.
 
Or we might never have existed at all. Freaky. So we should cherish everything. Even this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic