[java]program isnt asking me my favorite color

Discussion in 'Programming' started by raptrex, Jan 31, 2009.

  1. #1
    i get no error but my program should be asking me what my favorite color is
    import java.util.Scanner;
    
    public class Assignment2
    {
    	public static void main (String [] args)
    	{
    	String firstName,	middleName,	lastName;
    	int age, luckyNumber;
    	String color;
    	
    	Scanner keyboard = new Scanner(System.in);
    	System.out.println("What is your first name?");
    	firstName = keyboard.nextLine();
    	System.out.println("What is your middle name?");
    	middleName = keyboard.nextLine();
    	System.out.println("What is your last name?");
    	lastName = keyboard.nextLine();
    	System.out.println("How old are you?");
    	age = keyboard.nextInt();
    	System.out.println("What is your lucky number?");
    	luckyNumber = keyboard.nextInt();
    	System.out.println("What is your favorite color?");
    	color = keyboard.nextLine();
    	
    	String fullName = firstName + " " + middleName + " " + lastName;
    		System.out.println("A story about " + fullName + ":");
    	String fullNameCaps = fullName.toUpperCase();
    	char firstInitial = firstName.charAt(0);
    	char middleInitial = middleName.charAt(0);
    	char lastInitial = lastName.charAt(0);
    		System.out.println("\t" + fullNameCaps + " is " + firstInitial + middleInitial + lastInitial);
    		System.out.println("\t" + firstInitial + middleInitial + lastInitial + "'s favorite color is " + color + ", and " + firstName + " " + lastInitial + ". is " + luckyNumber);
    	}
    }
    Code (markup):

     
    raptrex, Jan 31, 2009 IP
  2. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #2
    Maybe the program doesn't care about your favorite color :D

    Does the program ask you all the questions until your lucky number then stops, or are all questions not appearing?

    Peace,
     
    Barti1987, Jan 31, 2009 IP