0% found this document useful (0 votes)
4 views

CS Programs 15

Uploaded by

rajagokulavarsni
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

CS Programs 15

Uploaded by

rajagokulavarsni
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1.

simple interest --

import java.util.Scanner;

class si

public static void main ( String [] args)

Scanner Sc= new Scanner ( System. in);

System. out.print(" Enter the principal : ");

float principal= Sc.nextInt ();

System.out.print( " Enter the rate :");

float rate = Sc.nextInt ();

System. out.print(" Enter the time :");

float time = Sc.nextInt ();

float interest =( principal * time * rate )/100;

System.out.println(" principal:"+ principal);

System.out.println (" Interest rate :"+ rate);

System.out.println ("Time Duration:"+ time);

System.out.println ("Simple Interest:"+ interest);

OUTPUT -

Enter the principal : 999 Enter the rate :333

Enter the time :7 principal:999.0 Interest


rate :333.0

Time Duration:7.0

Simple Interest:23286.69

2. compound interest --

import java.util.Scanner;
class compound

public static void main(String[] args)

Scanner sc = new Scanner(System.in);

System.out.print("Enter the principal: ");

double principal = sc.nextDouble();

System.out.print("Enter the rate: ");

double rate = sc.nextDouble();

System.out.print("Enter the time: ");

double time = sc.nextDouble();

System.out.print("Enter number of times interest is compounded: ");

int number = sc.nextInt();

double interest = principal * (Math.pow((1 + rate/100), (time * number)));

System.out.println("Principal: " + principal);

System.out.println("Interest Rate: " + rate);

System.out.println("Time Duration: " + time);

System.out.println("Number of Time interest Compounded: " + number);

System.out.println("Compound Interest: " + interest);

} OUTPUT -- Enter the principal: 1000 Enter the rate: 10 Enter the time: 3
Enter number of times interest is compounded: 1 Principal: 1000.0 Interest
Rate: 10.0 Time Duration: 3.0 Number of Time interest Compounded: 1

Compound Interest: 1331.0000000000005

3.

You might also like