Last active
January 29, 2018 10:02
-
-
Save nelvson/8c5a49c7f25bbbdec4ff6d81b2f7f9eb to your computer and use it in GitHub Desktop.
Week 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author nelvson | |
*/ | |
import java.util.Scanner; | |
public class Week3 { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
int X = reader.nextInt(); | |
int Y = reader.nextInt(); | |
if ((X%2==0 && Y%2==0) || (X%2==1 && Y%2==1)) | |
System.out.printf("Hasil penjumlahan %d dan %d adalah bilangan genap", X, Y); | |
else | |
System.out.printf("Hasil penjumlahan %d dan %d adalah bilangan ganjil", X, Y); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author nelvson | |
*/ | |
import java.util.Scanner; | |
public class Week3 { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
int X = reader.nextInt(); | |
int Y = reader.nextInt(); | |
int jumlah = X+Y; | |
if (jumlah%2==0) | |
System.out.printf("Hasil penjumlahan %d dan %d adalah bilangan genap", X, Y); | |
if (jumlah%2==1) | |
System.out.printf("Hasil penjumlahan %d dan %d adalah bilangan ganjil", X, Y); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author nelvson | |
*/ | |
import java.util.Scanner; | |
public class Week3 { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
int input = reader.nextInt(); | |
if ((input%2==0) && (input>0)) System.out.printf("%d adalah bilangan genap positif", input); | |
else if ((input%2==1) && (input>0)) System.out.printf("%d adalah bilangan ganjil positif",input); | |
else if ((input%2==0) && (input<0)) System.out.printf("%d adalah bilangan genap negatif",input); | |
else if ((input%2==1) && (input<0)) System.out.printf("%d adalah bilangan ganjil negatif",input); | |
else System.out.printf("Input yang dimasukkan adalah nol"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* @author nelvson | |
*/ | |
import java.util.Scanner; | |
public class Week3 { | |
public static void main(String[] args) { | |
Scanner reader = new Scanner(System.in); | |
char input = reader.next().charAt(0); | |
switch (input){ | |
case 'a' : case 'A' : | |
case 'e' : case 'E' : | |
case 'u' : case 'U' : | |
case 'i' : case 'I' : | |
case 'o' : case 'O' : | |
System.out.printf("%c merupakan huruf vokal\n", input); | |
break; | |
default : System.out.printf("%c merupakan huruf konsonan\n", input); | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment