Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Opg2ab
- {
- public static void main(String[] julebrus)
- {
- Scanner input = new Scanner(System.in);
- int teller = 1;
- do
- {
- double resultat;
- System.out.println("Skriv inn innskuddsbeløp i kr: ");
- double innskudd = input.nextDouble();
- System.out.println("Skriv inn rente i %: ");
- double rente = input.nextDouble();
- System.out.println("Skriv inn antall år i heltall: ");
- double tidsperiode = input.nextDouble();
- Beregner.utskrift(innskudd, rente, tidsperiode, Beregner.beregnet(resultat, innskudd, rente, tidsperiode));
- System.out.println("Prøve på nytt med nye tall? 1/0 = y/n");
- teller = input.nextInt();
- } while (teller != 0);
- }
- }
- class Beregner
- {
- public static double beregnet(double resultat, double innskudd, double rente, double tidsperiode)
- {
- resultat = innskudd * Math.pow(1+(rente/100), tidsperiode);
- return resultat;
- }
- public static void utskrift(double resultat, double innskudd, double rente, double tidsperiode)
- {
- System.out.println("Innskuddsbeløpet har etter " + tidsperiode + " og til " + rente + " vokst til: \n" + "Kr: ");
- }
- }
- C:\Users\Petter\Documents\it1103\øving 3\Opg2ab.java:20: error: variable resultat might not have been initialized
- Beregner.utskrift(innskudd, rente, tidsperiode, Beregner.beregnet(resultat, innskudd, rente, tidsperiode));
- ^
- 1 error
- Tool completed with exit code 1
Add Comment
Please, Sign In to add comment