• 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
  • 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

How to return value back to main?

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, this program takes user input for two applicants and assigns them scores based on SAT/ACT scores and GPA. For the test scores portion, I'm having trouble returning one final score back to main.
Someone suggested setting score = inputSATScore(console); but then what would happen if it were an ACT score?
Any help is appreciated, thank you!
(And sorry, but I can't figure out how to use clipboard to post my code).

public static double testScore(Scanner console)
{
System.out.print("do you have 1) SAT scores or 2) ACT scores?");
int test = console.nextInt();
double score = 0
if (test==1)
{
inputSATScore(console);
}
else{
inputACTScore(console);
}
return score;
}

public static double inputSATScore(Scanner console)
{
System.out.print("SAT math?");
double math = console.nextDouble();

System.out.print("SAT verbal?");
double verbal = console.nextDouble();

double score = (2 * verbal + math)/24;

return (double) score;
}

public static double inputACTScore(Scanner console)
{
System.out.print("ACT English?");
double English = console.nextDouble();

System.out.print("ACT math?");
double math = console.nextDouble();

System.out.print("ACT reading?");
double reading = console.nextDouble();

System.out.print("ACT science?");
double science = console.nextDouble();

double score = (2 * reading + English + math + science)/1.8;

return (double) score;
}
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashley Kin wrote:Someone suggested setting score = inputSATScore(console); but then what would happen if it were an ACT score?


You make the same change (i.e put 'score = ' at the start) to the inputACTScore(console) line.
 
Saloon Keeper
Posts: 10805
86
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows ChatGPT
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you mean:
double score = (2 * (verbal + math))/24;
 
reply
    Bookmark Topic Watch Topic
  • New Topic