Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static double potenz(double a, double b) throws InvalidExponentException, NotNaturalNumberException
- {
- double potenz_rechnung = 0.0; // Initialisierung der Variable Potenz_Rechnung
- double pruefung = 0.0;
- pruefung = ganzZahl(b);
- if(pruefung == 1.0 && b > 0.0)
- {
- potenz_rechnung = a;
- for (double i = 1.0; i < b; i++) // Schleife wird so lange ausgeführt bis i(Zähler) den Exponenten erreicht hat.
- {
- potenz_rechnung = potenz_rechnung * a;
- }
- }
- else
- {
- throw new InvalidExponentException();
- }
- return potenz_rechnung;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement