import java.util.Scanner; class Student{ int rollNumber; String name; } class StudentInfo{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); Student s1=new Student(); Student s2=new Student(); Student s3=new Student(); System.out.println("Enter roll of 1st Student:"); s1.rollNumber=sc.nextInt(); sc.nextLine(); System.out.println("Enter name of 1st Student:"); s1.name=sc.nextLine(); System.out.println("Enter roll of 2nd Student:"); s2.rollNumber=sc.nextInt(); sc.nextLine(); System.out.println("Enter name of 2nd Student:"); s2.name=sc.nextLine(); System.out.println("Enter roll of 3rd Student:"); s3.rollNumber=sc.nextInt(); sc.nextLine(); System.out.println("Enter name of 3rd Student:"); s3.name=sc.nextLine(); System.out.println("Name of First Student= "+s1.name); System.out.println("roll of First Student= "+s1.rollNumber); System.out.println("Name of Second Student= "+s2.name); System.out.println("roll of Second Student= "+s2.rollNumber); System.out.println("Name of Third Student= "+s3.name); System.out.println("roll of Second Student= "+s3.rollNumber); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter