Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Beginner Java code problems

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    7
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Beginner Java code problems

    Hey guys, I am a beginner to Java and have written a code to compare two students GPA, SAT and ACT Score to say which one is wrong with my code. Here is what I have so far, does anybody see what im doing wrong? Any help would be greatly appreciated, thanks!

     
     
    import java.util.*;
     
    public class Applicants {
    	public static void main(String[] args) {
    		Scanner console = new Scanner(System.in);
     
     
    public static double grades(Scanner console) {
    	System.out.print("What is the first applicant's GPA?");
    	double GPA1 = console.nextInt();
    	System.out.print("What is the first applicant's ACT Score?");
    	int ACT1 = console.nextInt();
    	System.out.print("What is the first applicant's SAT Score?");
    	int SAT1 = console.nextInt();
     
     
    	System.out.print("What is the second applicant's GPA?");
    	double GPA2 = console.nextInt();
    	System.out.print("What is the second applicant's ACT Score?");
    	int ACT2 = console.nextInt();
    	System.out.print("What is the second applicant's SAT Score?");
    	int SAT2 = console.nextInt();
     
     
    	if (GPA1>GPA2 && SAT1>SAT2 && ACT1>ACT2) {
    		System.out.println("Applicant 1 is more qualified than Apllicant 2.");
    	} else if (GPA1<GPA2 && SAT1<SAT2 && ACT1<ACT2);
    		System.out.println("Applicant 2 is more qualified than Apllicant 1.");
    	} else if (GPA1=GPA2 && SAT1=SAT2 && ACT1=ACT2);
    		System.out.println("Applicant 1 is as equally qualified as Apllicant 2.");
    }


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    1,676
    Thanks
    25
    Thanked 329 Times in 305 Posts

    Default Re: Beginner Java code problems

    else if (GPA1=GPA2 && SAT1=SAT2 && ACT1=ACT2);

    Single equals is an assignment operator. Double equals is a comparison.
    Use:
    GPA1==GPA2 instead of GPA1=GPA2 (for all the conditions in that else)

    EDIT:
    You should also not have a semicolon at the end of if statements.
    NOTE TO NEW PEOPLE LOOKING FOR HELP ON FORUM:

    When asking for help, please follow these guidelines to receive better and more prompt help:
    1. Put your code in Java Tags. To do this, put [highlight=java] before your code and [/highlight] after your code.
    2. Give full details of errors and provide us with as much information about the situation as possible.
    3. Give us an example of what the output should look like when done correctly.

    Join the Airline Management Simulation Game to manage your own airline against other users in a virtual recreation of the United States Airline Industry. For more details, visit: http://airlinegame.orgfree.com/

  3. The Following User Says Thank You to aussiemcgr For This Useful Post:

    return0 (October 14th, 2013)

Similar Threads

  1. Java code problems!
    By frenchsasha in forum What's Wrong With My Code?
    Replies: 3
    Last Post: May 26th, 2013, 04:10 PM
  2. [SOLVED] Beginner java: I'm getting one of three errors everytime I run my code?
    By Benner in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 21st, 2013, 12:52 AM
  3. java.lang.nullpointer exception in beginner code
    By Bobba in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 6th, 2012, 05:37 PM
  4. Beginner for Java, need help with this code I wrote
    By SilentNite17 in forum What's Wrong With My Code?
    Replies: 30
    Last Post: February 14th, 2012, 08:01 PM
  5. Beginner pleasee help with java code
    By chuy525 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 24th, 2011, 06:38 PM