Java - prompts the user for some personal data and then repeats it back to them.

Description

prompts the user for some personal data and then repeats it back to them.

Demo

import java.util.Scanner;
public class AskingQuestions {
    public static void main(String[] args) {

        Scanner keyboard = new Scanner(System.in);

        int age;//from w w w.j  av  a 2 s.c  o  m
        String heightFt;
        String heightIn;
        double weight;

        System.out.println("How old are you? ");
        age = keyboard.nextInt();

        System.out.println("How many feet tall are you? ");
        heightFt = keyboard.next();

        System.out.println("How many inches tall are you? ");
        heightIn = keyboard.next();

        System.out.println("How much do you weigh? ");
        weight = keyboard.nextDouble();

        System.out.println("So you are " + age + " old, " + heightFt + heightIn + " tall and " + weight + " heavy.");

    }
}

Related Topic