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

Thread: Hey guys need help kinda stuck

  1. #1
    Member
    Join Date
    Oct 2012
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Hey guys need help kinda stuck

    Ok here's the problem i have typed up most of the program and i cant get this little bit to work, cant think and this was a last resort
    So i have to output an message of the last two questions:
    - If BOTH answers are NO output “You appear to like saying No!”
    - If ONLY ONE of the answers was NO output “50-50, one yes and one no!”
    - If BOTH answers are YES output “You have a very agreeable nature!”
    and here's my code
    class Survey{
    public static void main(String[ ] args)
    {
    //Declare Variables
    char yes = 'y', no = 'n', answer1, answer2, answer3, answer4, answer5, answer6, answer7,answer8, answer9, answer10,answer11=0,answer12=0;
    int addition=0, subtraction=0, result1=0, result2=0;
    //Input
    System.out.print("Do you like sports Y/N: ");
    answer1 = Keyboard.readChar( );
    if (answer1 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer1 =='n')
    {
    subtraction=(subtraction + 1);
    }

    System.out.print("Do you like ireland Y/N: ");
    answer2 = Keyboard.readChar( );
    if (answer2 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer2 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like movies Y/N: ");
    answer3 = Keyboard.readChar( );
    if (answer3 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer3 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like europe Y/N: ");
    answer4 = Keyboard.readChar( );
    if (answer4 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer4 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like america Y/N: ");
    answer5 = Keyboard.readChar( );
    if (answer5 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer5 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like Manchester United Y/N: ");
    answer6 = Keyboard.readChar( );
    if (answer6 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer6 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like Dublin Y/N: ");
    answer7 = Keyboard.readChar( );
    if (answer7 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer7 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like ITB Y/N: ");
    answer8 = Keyboard.readChar( );
    if (answer8 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer8 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like computers Y/N: ");
    answer9 = Keyboard.readChar( );
    if (answer9 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer9 =='n')
    {
    subtraction=(subtraction + 1);
    }
    System.out.print("Do you like programming Y/N: ");
    answer10 = Keyboard.readChar( );
    if (answer10 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer10 =='n')
    {
    subtraction=(subtraction + 1);
    }

    //Output
    System.out.println("To Question 1o you like sports Y/N : You answered"+" "+ answer1);
    System.out.println("To Question 2o you like ireland Y/N: You answered"+" "+ answer2);
    System.out.println("To Question 3o you like movies Y/N: You answered"+" "+ answer3);
    System.out.println("To Question 4o you like europe Y/N: You answered"+" "+ answer4);
    System.out.println("To Question 5o you like america Y/N: You answered"+" "+ answer5);
    System.out.println("To Question 6o you like Manchester United Y/N:You answered"+" "+ answer6);
    System.out.println("To Question 7o you like Dublin Y/N:You answered"+" "+ answer7);
    System.out.println("To Question 8o you like ITB Y/N:You answered"+" "+ answer8);
    System.out.println("To Question 9o you like computers Y/N:You answered"+" "+ answer9);
    System.out.println("To Question 10o you like programming Y/N:You answered"+" "+ answer10);
    result1= addition;
    result2= subtraction;
    System.out.println("Thank you, you entered " + result1 + " Yes answers and " + result2 +" No answers ");

    if (result1 < 5)
    {
    System.out.print("Do you like music? Y/N : ");
    answer11=Keyboard.readChar( );
    }
    else if (answer11 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer11 == 'n')
    {
    subtraction=(subtraction + 1);
    }
    if (result1 < 5)
    {
    System.out.print("Do you like Batman? Y/N : ");
    answer12=Keyboard.readChar( );
    }
    else if (answer12 == 'y')
    {
    addition=(addition + 1);
    }
    else if (answer12 == 'n')
    {
    subtraction=(subtraction + 1);
    }



    if (answer11 == 'n')
    {
    }
    else if (answer12 == 'n')
    {
    System.out.println("You like to say no! don't you ");
    }



    }
    }

    i kinda gave up near the end cause i been trying it for so long please help, please


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Hey guys need help kinda stuck

    Hi. Please see the announcements page for the use of code tags in your post.

    You have not really asked a question. Where are you stuck and what do you need help with?

  3. #3
    Member
    Join Date
    Oct 2012
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Hey guys need help kinda stuck

    im sorry im new to this and im stuck at the end of my program and im trying to figure out a way how i can output messages eg If BOTH answers are NO output “You appear to like saying No!”
    - If ONLY ONE of the answers was NO output “50-50, one yes and one no!”
    - If BOTH answers are YES output “You have a very agreeable nature!
    and im trying to put them in so when i run the program the last two questions will say "You appear to like saying NO!", "50-50, one yes and one no!","You have a very agreeable nature"
    here's my code again
    class Survey{
       public static void main(String[ ] args)
    {
    //Declare Variables
       char yes = 'y', no = 'n', answer1, answer2, answer3, answer4, answer5, answer6, answer7,answer8, answer9, answer10,answer11=0,answer12=0;
       int addition=0, subtraction=0, result1, result2;
    //Input
       System.out.print("Do you like sports Y/N:     ");
       answer1 = Keyboard.readChar( );
       if  (answer1 == 'y')
       {
          addition=(addition + 1);
       }
        else if (answer1 =='n')
         {
          subtraction=(subtraction + 1);
         }
     
           System.out.print("Do you like ireland Y/N:     ");
    	     answer2 = Keyboard.readChar( );
    	     if  (answer2 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer2 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like movies Y/N:     ");
    	     answer3 = Keyboard.readChar( );
    	     if  (answer3 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer3 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like europe Y/N:     ");
    	     answer4 = Keyboard.readChar( );
    	     if  (answer4 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer4 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like america Y/N:     ");
    	     answer5 = Keyboard.readChar( );
    	     if  (answer5 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer5 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like Manchester United Y/N:     ");
    	     answer6 = Keyboard.readChar( );
    	     if  (answer6 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer6 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like Dublin Y/N:     ");
    	     answer7 = Keyboard.readChar( );
    	     if  (answer7 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer7 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like ITB Y/N:     ");
    	     answer8 = Keyboard.readChar( );
    	     if  (answer8 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer8 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like computers Y/N:     ");
    	     answer9 = Keyboard.readChar( );
    	     if  (answer9 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer9 =='n')
    	       {
          subtraction=(subtraction + 1);
             }
           System.out.print("Do you like programming Y/N:     ");
    	     answer10 = Keyboard.readChar( );
    	     if  (answer10 == 'y')
    	     {
    	        addition=(addition + 1);
    	     }
    	      else if (answer10 =='n')
    	     {
              subtraction=(subtraction + 1);
    	     }
     
    //Output
            System.out.println("To Question 1:Do you like sports Y/N : You answered"+" "+ answer1);
            System.out.println("To Question 2:Do you like ireland Y/N: You answered"+" "+ answer2);
            System.out.println("To Question 3:Do you like movies Y/N: You answered"+" "+ answer3);
            System.out.println("To Question 4:Do you like europe Y/N: You answered"+" "+ answer4);
            System.out.println("To Question 5:Do you like america Y/N: You answered"+" "+ answer5);
            System.out.println("To Question 6:Do you like Manchester United Y/N:You answered"+" "+ answer6);
            System.out.println("To Question 7:Do you like Dublin Y/N:You answered"+" "+ answer7);
            System.out.println("To Question 8:Do you like ITB Y/N:You answered"+" "+ answer8);
            System.out.println("To Question 9:Do you like computers Y/N:You answered"+" "+ answer9);
            System.out.println("To Question 10:Do you like programming Y/N:You answered"+" "+ answer10);
            result1= addition;
            result2= subtraction;
            System.out.println("Thank you, you entered " + result1 + " Yes answers and " + result2 +" No answers ");
     
            if (result1 < 5)
            {
             System.out.print("Do you like music?  Y/N :         ");
             answer11=Keyboard.readChar( );
            }
            else if (answer11 == 'y')
            {
             addition=(addition + 1);
            }
            else if (answer11 == 'n')
            {
             subtraction=(subtraction + 1);
            }
             if (result1 < 5)
            {
             System.out.print("Do you like Batman?  Y/N  :           ");
             answer12=Keyboard.readChar( );
            }
            else if (answer12 == 'y')
            {
             addition=(addition + 1);
            }
            else if (answer12 == 'n')
            {
             subtraction=(subtraction + 1);
            }
     
            if (answer11 == 'n')
            {
            }
            else if (answer12 == 'n')
            {
            System.out.println("You like to say NO! don't you");
            }
     
        }
    }

  4. #4
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Hey guys need help kinda stuck

    As beautiful as a poem. I read that the first time you posted it. Thank you so much for letting us read it again.

    I know what you want. I asked what are you stuck on and what you need help with?

    Reading How to ask questions the smart way may help you in getting help.

  5. #5
    Member
    Join Date
    Oct 2012
    Posts
    32
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Hey guys need help kinda stuck

    its ok it just solved it thank you

Similar Threads

  1. Hey guys I need some help
    By kenamine in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 25th, 2012, 10:10 PM
  2. Hey guys!!
    By Toni8810 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: August 8th, 2012, 07:27 AM
  3. Hey guys
    By felixchon in forum Member Introductions
    Replies: 1
    Last Post: March 13th, 2011, 08:50 AM
  4. Hey guys
    By StarKannon in forum Member Introductions
    Replies: 2
    Last Post: February 2nd, 2011, 04:58 AM