You are on page 1of 6

ERICA MAE D.

RELEVO

BIT-CPT1201

//APPLICATION OF ARRAY CONCEPTS-USING KEYBOARD SCANNER

import java.util.Scanner;
/**
* This program shows values being read into an array's
* elements and then displayed.
*/
public class Confidential {

public static void main(String[] args)


{

String[] Name = new String[3]; // Name of Students

// Create a Scanner object for keyboard input.


Scanner keyboard = new Scanner(System.in);

System.out.println("Enter name of Students");

// Get student 1's file(Name).


System.out.print("Student 1: ");
Name[0] = keyboard.next();

// Get employee 2's file(Name).


System.out.print("Student 2: ");
Name[1] = keyboard.next();

// Get employee 3's file(Name).


System.out.print("Student 3: ");
Name[2] = keyboard.next();

// Display the values in the array.


System.out.println("The student names you entered are:");
System.out.println("Name of the First student is "+Name[0]);
System.out.println("Name of the Second student is "+Name[1]);
System.out.println("Name of the Third student is "+Name[2]);

}
import java.util.Scanner;
/**
* This program shows values being read into an array's
* elements and then displayed.
*/
public class StudentAges {

public static void main(String[] args) {

int[]Age =new int [3];// Student's Age


// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);

System.out.println("Enter the Age of Students");

// Get student 1's file(Age).


System.out.print("Student 1: ");
Age[0] = keyboard.nextInt();

// Get employee 2's file(Name).


System.out.print("Student 2: ");
Age[1] = keyboard.nextInt();

// Get employee 3's file(Name).


System.out.print("Student 3: ");
Age[2] = keyboard.nextInt();

// Display the values in the array.


System.out.println("The student ages you entered are:");
System.out.println("Age of the First student is
"+Age[0]);
System.out.println("Age of the Second student is
"+Age[1]);
System.out.println("Age of the Third student is
"+Age[2]);

}
import java.util.Scanner;
/**
* This program shows values being read into an array's
* elements and then displayed.
*/
public class Height {

public static void main(String[] args) {

double[]StudentHeight=new double[3];// Height of Student


// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);

System.out.println("Enter the Height of Students");

// Get student 1's file(Height).


System.out.print("Student 1: ");
StudentHeight[0] = keyboard.nextDouble();

// Get employee 2's file(Height).


System.out.print("Student 2: ");
StudentHeight[1] = keyboard.nextDouble();

// Get employee 3's file(Height).


System.out.print("Student 3: ");
StudentHeight[2] = keyboard.nextDouble();

// Display the values in the array.


System.out.println("The student height you entered are:");
System.out.println("Height of the First student is "+StudentHeight[0]);
System.out.println("Height of the Second student is
"+StudentHeight[1]);
System.out.println("Height of the Third student is "+StudentHeight[2]);

You might also like