0% found this document useful (0 votes)
61 views6 pages

Java Programming Practice Tasks

This document contains 7 Java programs with sample code and output to practice programming concepts like printing text, calculating area of a triangle, checking even/odd numbers, increment/decrement operators, and logical operators. The programs were written by Prasetya Adi Wiraguna, a student in the Electronics Engineering program to complete an assignment.
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)
61 views6 pages

Java Programming Practice Tasks

This document contains 7 Java programs with sample code and output to practice programming concepts like printing text, calculating area of a triangle, checking even/odd numbers, increment/decrement operators, and logical operators. The programs were written by Prasetya Adi Wiraguna, a student in the Electronics Engineering program to complete an assignment.
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

TUGAS PEMROGRAMAN

LATIHAN PRAKTIKUM JAVA

Oleh : Prasetya Adi Wiraguna


D41161026
Teknik Elektronika (Karyawan)
1. [Link]

Script :

public class ProgramCetak1{

public static void main(String [] args){

[Link](" Prasetya Adi Wiraguna");

Output :

2. [Link]

Script :

public class ProgramCetak2{

public static void main(String [] args){

[Link]("Prasetya Adi Wiraguna");

[Link]("T. Elektronika");

[Link]("D41161026");

3. [Link]

Script :
public class ProgramLuas{
public static void main(String [] args){
double alas;
double tinggi;
double luas;
alas=20;
tinggi=10;
luas=alas*tinggi/2;
[Link]("Alas segitiga = "+alas);
[Link]("Tinggi segitiga = "+tinggi);
[Link]("Jadi Luas segitiga = "+luas);
}
}
Output :

4. [Link]
Script :
import [Link];
public class ProgramBilangan {
public static void main(String[] args) {
Scanner s=new Scanner([Link]);
[Link]("Input sebuah bilangan : ");
int bilangan=[Link]();
if (bilangan % 2 == 1) {
[Link](bilangan+" Adalah bilangan GANJIL ");
}
else
[Link](bilangan+" Adalah bilangan GENAP ");
}
}
Output :

5. [Link]

Script :

public class OperatorIncrement {

public static void main (String [] args) {

int x=4;

[Link](++x);

[Link](x++);

Output :

6. [Link]

Script :

public class OperatorDecrement {

public static void main (String [] args) {

int x=4;

[Link](--x);

[Link](x--);

}
Output :

7. [Link]

Script :

public class OperatorLogika {


public static void main (String [] args) {

int N=92;
if(N >=80 && N<=100){
[Link]("Nilai anda :"+N);
[Link]("Grade A");
}else if(N >=65 && N <=79){
[Link]("Nilai anda :"+N);
[Link]("Grade B");
[Link]("Nilai anda :"+N);
}else if(N >= 60 && N<=64 ){
[Link]("Nilai anda :"+N);
[Link]("Grade C");
}else if(N >=40 && N<=59){
[Link]("Nilai anda :"+N);
[Link]("Grade D");
}else{
[Link]("Nilai anda :"+N);
[Link]("Grade E");
}
}
}
Output :
Jika Nilai <= 100

Jika Nilai < 40

You might also like