Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Code a Java compound interest calculator in 7 minutes! 💸
Play lesson

Java tutorial for beginners ☕ - Code a Java compound interest calculator in 7 minutes! 💸

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse import java.util.Scanner; public class Main { public static void main(String[] args) { // Compound interest calculator Scanner scanner = new Scanner(System.in); double principal; double rate; int timesCompounded; int years; double amount; System.out.print("Enter the principal amount: "); principal = scanner.nextDouble(); System.out.print("Enter the interest rate (in %): "); rate = scanner.nextDouble() / 100; System.out.print("Enter the # of times compounded per year: "); timesCompounded = scanner.nextInt(); System.out.print("Enter the # of years: "); years = scanner.nextInt(); amount = principal * Math.pow(1 + rate / timesCompounded, timesCompounded * years); System.out.printf("The amount after %d years is $%.2f", years, amount); scanner.close(); } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere