Using Loop Statement, create a program that will be able to display student information such as, last name, first name, middle name, address.
Sample output:
Enter number of student: 2
Enter Last name: Sinco
Enter First name: Eddiemar
Enter Middle name: Garcia
Enter Address: Cabugao
Student 1
Name: Eddiemar Garcia Sinco
Address: Cabugao
Enter Last name: Sinco
Enter First name: Kent
Enter Middle name: Tiongson
Enter Address: Cabugao
Student 2:
Name: Kent Tiongson Sinco
Address: Cabugao
import java.util.Scanner;
public class App {
/**
* The start point of the program
*
* @param args
*
*/
public static void main(String[] args) {
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter number of student: ");
int N = keyBoard.nextInt();
keyBoard.nextLine();
for (int i = 0; i < N; i++) {
System.out.print("Enter Last name: ");
String lastName = keyBoard.nextLine();
System.out.print("Enter First name: ");
String firstName = keyBoard.nextLine();
System.out.print("Enter Middle name: ");
String middleName = keyBoard.nextLine();
System.out.print("Enter Address: ");
String address = keyBoard.nextLine();
System.out.println("\nStudent " + (i + 1));
System.out.println("Name: " + firstName + " " + middleName + " " + lastName);
System.out.println("Address: " + address+"\n\n");
}
keyBoard.close();
}
}
Comments
Leave a comment