Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more: (untagged)
Java
//expressions used to calculate the weight for each exam and hw assignment.

    public static double grades(double weightedHomeworkScore, double weightedmid1Score, double weightedfinal2Score) {
        double weightedHomeworkScore=(score1+score2+score3+(sections*4)/maxPossible1+maxPossible2+maxPossible3+sectionsMax)*homeWeight;
        return round2(weightedHomeworkScore);
        double weightedmid1Score=((mid1/100)*mid1Weight);
        return round2(weightedmid1Score);
        double weightedfinal2Score=((final2/100)*final2Weight);
        return round2(weightedfinal2Score);
    }                                                                         
    
    // Returns the given double value rounded to the nearest hundredth. 

    public static double round2(double number) { 
        return Math.round(number * 100.0) / 100.0;
        System.out.println("Course grade=" + round2(int grades));


What I have tried:

I am 4 weeks into learning java and I have fiddled around with everything around it as well as switching the design of that last print statement. I am not sure what to try to fix this so I can turn in the assignment.
Posted
Updated 3-Oct-17 20:09pm
v2
Comments
PIEBALDconsult 3-Oct-17 23:31pm    
Aaannnddd... what seems to be the trouble?
Please use Improve question to add detail and context -- sample input, expected output, actual output, etc.
Member 13444111 4-Oct-17 0:15am    
I am real sorry! That is also part of the problem, I am not even sure how to ask these questions!

This is an assignment due for 'Intro to Java' course. I am using BlueJ for this class. These are the last two methods I introduced to the program. I am not sure why but the debugger (is that what it is called?) does not accept the very last line of the code:

System.out.println("Course grade=" + round2(int grades)); // The end is the issue. It doesnt like (int <g>rades)<)>;
In other words, it says "class expected" for the <g> and "';' expected" for the <)>.

I have tried different variations. For the life of me, I cannot compile this and turn it in. Maybe I would see more clearly if I was not stressed for, ironically, a grade. My professor is 24 hours behind my question. I get one sentences back. The worst part is the line of code is the one that the prompt provides you to include in order to output the grade the program computed.

I just to get this to compile and that line with those errors above are making it very difficult to do so.

I hope this helps, thanks!
GKP1992 4-Oct-17 0:14am    
I cannot say what is the problem you face but multiple return statements in a single code flow never work. A return statement means that the execution of the code block (in this case the method) is finished and the control will exit the method, so for your grades method, after the line
return round2(weightedHomeworkScore);
nothing will be executed. You might wanna reconsider your method and think about what you want it to do.
Member 13444111 4-Oct-17 0:25am    
I replied and did not see your response. Thanks for replying.

That entire method was supplied to the students via the prompt from the course 'Intro to Java' that I am taking. I mentioned below, I can't seem to utilize the resource of my "professor" or "Dr" that is monitoring the class. I am not that knowledgeable in Java to write that anyway. I barely understand the Scanner console that has been applied.

I am incredibly grateful of this platform to see different examples or and ask questions when I have it. I have too much on my plate to try and teach myself coding or programming, especially with only words, so-to-speak. I am very much a visual learner. I also believe I think too much and I try understand why or how it all fits. It is increasingly obvious that I need to avoid doing that.

Honestly, with your response and the suggested code, if it compiles, then you are a god send. I am more than motivated to learn this and I will. The amount of studying and note taking will make more sense as I visually see and can practice.

Thank you for taking the time to help me.
Member 13444111 4-Oct-17 0:35am    
GKP1992 Oh my god. I just reread what you said and I understand what you meant. Sorry about that. That is how difficult this is for me right now. To be honest, the last line of code above used to be under

return round2(weightedfinal2Score);

but I was getting <identifier> errors as well.

1 solution

Hello,

I think you have a few things to know (learn) before you do the assignment. Do not worry of the time you have left, once you have the basic understandings of the program flow (viz. the program is encapsulated in a class and needs a main method to run), variable declaration and usage (variable vs parameter), method declaration and usage you'll not take more than 2 hours to complete it.

Your program won't run in it's current state. Start by creating a class and then the main method, then take it from there.

The compiler errors will keep you on track.

I'd recommend Head First Java as a starter.

Happy learning.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900