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 3 of 3

Thread: Could anyone please advise me on this unfinished code? THANK YOU! (I know there are errors)

  1. #1
    Junior Member
    Join Date
    Mar 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Could anyone please advise me on this unfinished code? THANK YOU! (I know there are errors)

    import java.util.Scanner; //allows for input

    public class ASG03 {

    public static void main(String[] args) {
    Scanner input = new Scanner(System.in); //allows for input

    //Step 1 - Declare and initialize variables
    String candidateName = "";
    String responseE = "";

    int option = 0;
    double score = 0;


    if (score <=85)
    responseE = "Definite";
    else if (score <=70)
    responseE = "Likely";
    else if (score <=60)
    responseE = "Maybe";
    else
    responseE = "No";

    String responseI = "";

    if (score <=85)
    responseI = "Yes";
    else if (score <=70)
    responseI = "Yes";
    else if (score <=60)
    responseI = "Yes";
    else
    responseI = "No";

    //Step 2 - Process input

    System.out.println("Enter candidate name: ");
    candidateName = input.nextLine();
    System.out.println("Enter score 0 -100: ");
    score = input.nextDouble();
    System.out.println();



    System.out.println("Enter 1 to set employment category ");
    System.out.println("Enter 2 to set interview possibility ");
    System.out.println("Enter 3 to view a sample test question ");
    System.out.println("Enter option now -> ");
    option = input.nextInt();





    //Step 3 and 4 - Process calculations and output
    switch(option)
    {
    case 1:
    System.out.println("You are now setting the employment category...");
    //can use nested if else
    System.out.println("Employment category = " + responseE);

    break;


    case 2:
    System.out.println("You are now setting the interview possibilities...");
    System.out.println("Interview possibilites = " + responseI);



    break;

    case 3:
    System.out.println("You are now viewing a sample test question...");
    //use random and power from Math library


    default:


    }//end of switch

    }//end of main

    }//end of class


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Could anyone please advise me on this unfinished code? THANK YOU! (I know there are errors)

    Please copy the full text of the error messages and paste it here.

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Feb 2013
    Posts
    42
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Default Re: Could anyone please advise me on this unfinished code? THANK YOU! (I know there are errors)

    Well one problem I can see is that you are scanning for the name and score after the if-statements that test them. The if-statements would have already ran when the variables are filled with the information that is inputted.

Similar Threads

  1. Someone help me with my code it has some errors? Thanks!
    By skitheeast8 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 1st, 2012, 06:37 PM
  2. weird errors in my code
    By jobje325 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: August 17th, 2012, 11:15 AM
  3. Code is giving an error in console, but there are no errors apparent in the code!
    By JamEngulfer221 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 15th, 2011, 09:30 PM
  4. Need Advise!!!
    By Mr.777 in forum Member Introductions
    Replies: 1
    Last Post: May 16th, 2011, 09:36 AM
  5. Please check the code for the errors
    By nrao in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 16th, 2010, 05:37 PM