Help coderanch get a
new server
by contributing to the fundraiser
    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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Having trouble organizing the layout of my program?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi, I need to create a program that accepts user input for two applicants: either SAT or ACT scores, and then GPA. Then it will calculate and print a "score" based on given equations for each applicant and print out which applicant is the better choice.

I'm having trouble just thinking about the layout of my program; should I just have separate methods for test scores and GPA, and then have identical methods for the applicants?
And I also can't figure out how to use my returns properly for this purpose.

Any help and feedback is appreciated, thank you!


This is the majority of my program so far, and as you can see, it has a lot of parts that lead to nowhere as of now. I think the errors have something to do with my scanner first of all? And then... the returns.


 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi Ashley,

Welcome to the ranch...

Quick things -

1. You have the console variable as a static instance variable. But you have created another local variable console in your main() method. So when you think you have initialized the instance static variable console, the local variable is the one that gets initialized. So remove the declaration from the main() method.

2. The instance variables are common to all the methods. So you do not want to have them as method arguments.

3. Your methods testScore() and gpa() does not return anything but have been marked as returning int and double respectively.

Did you forget to copy paste the class declaration?
 
Marshal
Posts: 79532
380
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
What instance variables? I can see no instance variables. In fact everything is static. That is usually a mistake. In fact, having a method for first scores and one for second scores suggests you are mistaken in your design.

What you want is a class which represents a pupil or similar. Then you set up two instances (if possible a 2-element array). Then you can call enterScores() methods and displayScores() methods on each. You want to avoid making everything static. You also need to learn about return types for methods; your gpa method says it returns a double, but returns nothing. The compiler won’t be happy with that.
Yes, there does appear to be code missing at the beginning of the post.
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

My earlier post states -
static instance variable


It's a mistake. A static variable(class variable) is different from the instance variable. Thanks Campbell for pointing that.
 
Campbell Ritchie
Marshal
Posts: 79532
380
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Closing thread because the discussion appears to continue here.
 
The first person to drink cow's milk. That started off as a dare from this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
    Bookmark Topic Watch Topic
  • New Topic