Advertisement
Varasku

Potęga x

Oct 25th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. package pętlee9;
  2.  
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class PętleE9 {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. int licznik =1 ,n ;
  11. double x, potęga=1;
  12. Scanner sc = new Scanner(System.in);
  13.  
  14. System.out.println("Podaj x");
  15.  
  16. x=sc.nextInt(); sc.nextLine();
  17. System.out.println("Podaj n");
  18.  
  19. n=sc.nextInt(); sc.nextLine();
  20. while(licznik <= n) {
  21.  
  22. potęga *= x;
  23. licznik += 1;
  24.  
  25. }
  26.  
  27.  
  28. System.out.println("Potęga= " + potęga);
  29.  
  30.  
  31.  
  32.  
  33. }
  34.  
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement