Java Program to print a input entered by user


Program
import java.util.Scanner; public class PrintValue { public static void main(String[] args) { Scanner s = new Scanner(System.in); System.out.println("Enter a Integer Value: "); int int1 = s.nextInt(); System.out.println("Enter a Float Value: "); float float2 = s.nextFloat(); System.out.println("Enter a Double Value: "); double double3 = s.nextDouble(); System.out.println("Enter a Long Value: "); long long4 = s.nextLong(); System.out.println("Enter a Short Value: "); short short5 = s.nextShort(); System.out.println("Enter a Boolean Value: "); boolean boolean6=s.nextBoolean(); System.out.println("Enter a Character Value: "); char char7=s.next().charAt(0); System.out.println("Enter a String Value:(only one word "); String str8 = s.next(); System.out.println("Enter a Integer Value: (Multiple Line)"); String str9 = s.nextLine(); System.out.println("You entered: Integer " + int1 ); System.out.println(" Float "+ float2 ); System.out.println(" Double "+ double3 ); System.out.println(" Long "+ long4 ); System.out.println(" Short "+ short5 ); System.out.println(" boolean "+ boolean6 ); System.out.println(" char "+ char7 ); System.out.println(" String1 "+ str8 ); System.out.println(" String2 "+ str9); } }
Input
Output