Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

How can i put my result into another method to do something else to it?

 
Ranch Hand
Posts: 52
2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just a simple program to take in marks and give a total

here is my code



getting an error on this line



any help appreciated
 
Saloon Keeper
Posts: 10669
228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The compiler complains that you're referring to totalScore from the main() method, because totalScore is a member of Module an main() is not. You can only refer to totalScore by accessing an instance of Module.

However, there's a better fix. Note that your getGrade() method doesn't use the ts parameter at all. You can remove it and then call getGrade() without passing totalScore.

You have other issues:

A method with a name starting with get- is generally expected to return something. Your getMark() and getGrade() methods don't return anything. Name them promptForMark() and printGrade() instead.

The studentScore field is overwritten in different calls to getMark(). You probably want to make it a local variable instead of a private member.

The moduleName, projectOneMark, projectTwoMark, examMark and grade fields are unused.
 
I yam what I yam and that's all that I yam - the great philosopher Popeye. Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!