This program takes input from the user for various types of data such as String, char, int, and float. It then prints out the input values back to the user.
import java.util.Scanner; public class Different_Input { public static void main(String args[]) throws Exception { String name,gen; char gra; int age,tot; float per; Scanner input = new Scanner(System.in); System.out.print("Enter the Name : "); name = input.nextLine(); System.out.print("Enter Gender (Male/Female) : "); gen = input.next(); System.out.print("Enter the Age : "); age = input.nextInt(); System.out.print("Enter the Total : "); tot = input.nextInt(); System.out.print("Enter the Percentage : "); per = input.nextFloat(); System.out.print("Enter the Grade : "); gra = input.next().charAt(0); System.out.println("Name : " + name); System.out.println("Gender : " + gen); System.out.println("Age : " + age); System.out.println("Total : " + tot); System.out.println("Percentage : " + per); System.out.println("Grade : " + gra); } }
Enter the Name : Joes Enter Gender (Male/Female) : Male Enter the Age : 38 Enter the Total : 422 Enter the Percentage : 84.40 Enter the Grade : B Name : Joes Gender : Male Age : 38 Total : 422 Percentage : 84.4 Grade : B
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions