Skip to content

Instantly share code, notes, and snippets.

@halimarm
Last active March 20, 2020 15:40
Show Gist options
  • Save halimarm/912975506f190a03a616b5cbe48fc0c4 to your computer and use it in GitHub Desktop.
Save halimarm/912975506f190a03a616b5cbe48fc0c4 to your computer and use it in GitHub Desktop.
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package test;
/**
*
* @author Halim
*/
public class test {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// Question 1
String kata = "qwertyuiopasdfghjklzxcvbnm";
char[] charArr = kata.toCharArray();
String vokal = "";
String konson = "";
for (int i = 0; i < charArr.length; i++) {
if (charArr[i] == 'a' || charArr[i] == 'i' || charArr[i] == 'u' || charArr[i] == 'e' || charArr[i] == 'o') {
vokal += charArr[i];
} else {
konson += charArr[i];
}
}
System.out.println("Konsonan : "+konson);
System.out.println("Vokal : "+vokal);
// ##############################################################################
// Question 2
for (int i = 1; i <= 6; i++) {
for (int j = 1; j <= i; j++) {
System.out.print(i + " ");
}
System.out.println("");
System.out.println("");
}
// ##############################################################################
// Question 3
int t1 = 1, t2 = 1;
for (int i = 1; i <= 10; ++i) {
System.out.print(t1 + " ");
int sum = t1 + t2;
t1 = t2;
t2 = sum;
}
// ##############################################################################
// Question 4
int i = 1, n = 20, t1 = 1, t2 = 1;
while (i <= n)
{
System.out.print(t1 + " ");
int sum = t1 + t2;
t1 = t2;
t2 = sum;
i++;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment