Advertisement
Zidinjo

Untitled

Dec 4th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. static double potenz(double a, double b) throws InvalidExponentException, NotNaturalNumberException
  2. {
  3. double potenz_rechnung = 0.0; // Initialisierung der Variable Potenz_Rechnung
  4. double pruefung = 0.0;
  5. pruefung = ganzZahl(b);
  6.  
  7. if(pruefung == 1.0 && b > 0.0)
  8. {
  9. potenz_rechnung = a;
  10. for (double i = 1.0; i < b; i++) // Schleife wird so lange ausgeführt bis i(Zähler) den Exponenten erreicht hat.
  11. {
  12. potenz_rechnung = potenz_rechnung * a;
  13. }
  14. }
  15. else
  16. {
  17. throw new InvalidExponentException();
  18. }
  19. return potenz_rechnung;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement