SHARE
TWEET

14 - Lista 1 Lab 2

RastrianDEV Aug 20th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.*;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         int y=0;
  6.         Scanner x = new Scanner(System.in);
  7.         System.out.println("Insira o valor de a:");
  8.         int a = x.nextInt();
  9.         System.out.println("Insira o valor de b:");
  10.         int b = x.nextInt();
  11.         int expect_result = (int) Math.pow(a, b);
  12.         int result = 1;
  13.         while (result!=expect_result) {
  14.             result*=a;
  15.         }
  16.         System.out.println(expect_result+"="+result);
  17.         result=1;
  18.         while (b!=0) {
  19.             result*=a;
  20.             b--;
  21.         }
  22.         System.out.println(expect_result+"="+result);
  23.     }
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top