0% found this document useful (0 votes)
3 views3 pages

TestFive Java

The Java program generates random heights for 20 students and identifies those eligible for a sports event based on height. It also determines the tallest student and counts the number of words, capital letters, and vowels in the name 'Teuku Neo Quinn'. The program outputs the results of these calculations to the console.

Uploaded by

kelascef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views3 pages

TestFive Java

The Java program generates random heights for 20 students and identifies those eligible for a sports event based on height. It also determines the tallest student and counts the number of words, capital letters, and vowels in the name 'Teuku Neo Quinn'. The program outputs the results of these calculations to the console.

Uploaded by

kelascef
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

package teuku.neo.quinn.

main;

public class TestFive {

public static void main(String[]args){

int nrOfStudents = 20;

int[] hight = new int [nrOfStudents];

int index = 0;

int theHighest = 0;

//Loop menghitung jumlah tinggi murid

for (int i = 0; i < nrOfStudents; i++ )

hight[i] = 150 + (int) (Math.random() * 60);

for (int i = 0; i < nrOfStudents; i++ )

System.out.println("The height of student = " + (i + i) + " : " + hight[i]);

//Loop menghitung jumlah murid yang ikut porseni

System.out.println("\n");

System.out.println("These students are selected for porseni : ");

for (int i = 0; i < nrOfStudents; i++){

if(hight[i] >= 170){

System.out.println("Student = " + (i + 1) + " : " + hight[i]);

//Loop menghitung jumlah murid tertinggi

System.out.println("\n");

theHighest = hight[0];

for (int i = 0; i < nrOfStudents; i++ ){


if (hight[i] > theHighest){

theHighest = hight[i];

index = i;

System.out.println("The highest students = " + (index + 1) + " : " + theHighest);

//Menghitung jumlah kata

String name="Teuku Neo Quinn";

char[] nameChars;

int nrOfWords=0;

nameChars=name.toCharArray();

for (int i =0; i<name.length(); i++)

if (nameChars[i]==' ')

nrOfWords=nrOfWords+1;

System.out.println("The Number of Words :" + (nrOfWords+1));

int nrOfCapitals=0;

for (int i =0; i<name.length(); i++)

if((nameChars[i]>=65)&&(nameChars[i]<=90))

nrOfCapitals=nrOfCapitals+1;

System.out.println("The number of Capital :" + nrOfCapitals);

int nrOfVocal=0;

for (int i =0; i<name.length(); i++)

if(nameChars[i]=='a'|nameChars[i]=='i'|nameChars[i]=='u'|nameChars[i]=='e'|nameChars[i]=='o')

{
nrOfVocal=nrOfVocal+1;

System.out.println("The number of Vocal :" + nrOfVocal);

You might also like