/*
* 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 Matkul;
/**
*
* @author kumal
*/
public class M7_pangkatFor {
public static void main(String[] args) {
java.util.Scanner input = new java.util.Scanner(System.in);
System.out.print("Masukkang angka: ");
int angka = input.nextInt();
System.out.print("Masukkang pangkat: ");
int pangkat = input.nextInt();
while (pangkat<0) {
System.out.print("Masukkan pangkat positif: ");
pangkat = input.nextInt();
}
for (int i=0; i<=pangkat; i++) {
int hasil = (int) Math.pow(angka, i);
System.out.println(angka + " ^ " + i + " = " + hasil);
}
}
}
Like this:
Like Loading...
Related