Sim88 0 Posted June 28, 2019 Report Share Posted June 28, 2019 Cześć, Jestem nowy na forum i nie mniej nowy w programowaniu. Mam za sobą zaledwie ok. 10 godzin nauki Javy, więc wiem, że nic nie wiem Wykonałem proste ćwiczenie z użyciem pętli: public class Main { public static void main(String[] args) { for (int i=1; i<31; i++) { System.out.println(calculateInterest(10000, i)); } } public static double calculateInterest (double amount, double interestRate) { return (amount * (interestRate/100)); } } Spodziewałem się otrzymać taki wynik: 100.0 200.0 300.0 400.0 500.0 600.0 700.0 800.0 900.0 1000.0 1100.0 1200.0 1300.0 1400.0 1500.0 1600.0 1700.0 1800.0 1900.0 2000.0 2100.0 2200.0 2300.0 2400.0 2500.0 2600.0 2700.0 2800.0 2900.0 3000.0 Tymczasem, ku mojemu zaskoczeniu, komputer zwrócił takie coś: 100.0 200.0 300.0 400.0 500.0 600.0 700.0000000000001 800.0 900.0 1000.0 1100.0 1200.0 1300.0 1400.0000000000002 1500.0 1600.0 1700.0000000000002 1800.0 1900.0 2000.0 2100.0 2200.0 2300.0 2400.0 2500.0 2600.0 2700.0 2800.0000000000005 2900.0 3000.0 Skąd biorą się te ułamki? Quote Link to post Share on other sites
Bartosz Wójcik 18 Posted January 7, 2020 Report Share Posted January 7, 2020 Chyba masz podkręcony procesor Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.