Program Java For
Program Perkalian, Pembagian, Pertambahan, Pengurangan
import java.util.*;
class contohfor1{
public static void main(String[]args) {
Scanner input = new Scanner(System.in);
System.out.print("Lebokno Angka e(Perkalian): ");
double angka = input.nextInt();
for (int index=1; index<=10; index++){
System.out.println(angka+" x "+(index)+" = "+(angka*(index)));
}
System.out.print("Lebokno Angka e(Pembagian): ");
double angka1 = input.nextInt();
for (int index1=1; index1<=10; index1++){
System.out.println(angka1+" : "+(index1)+" = "+(angka1/(index1)));
}
System.out.print("Lebokno Angka e(Pertambahan): ");
double angka2 = input.nextInt();
for (int index2=1; index2<=10; index2++){
System.out.println(angka2+" + "+(index2)+" = "+(angka2+(index2)));
}
System.out.print("Lebokno Angka e(Pengurangan): ");
double angka3 = input.nextInt();
for (int index3=1; index3<=10; index3++){
System.out.println(angka3+" - "+(index3)+" = "+(angka3-(index3)));
}
}
}
Hasil Output
Komentar
Posting Komentar