Welcome To The World Of Java

This site will teach you the basics of Java. It is not necessary to have any prior programming experience.

Java program to calculate the Simple Interest and Input by the user.

Somdeb Burman | 10:26:00 AM | 0 comments

import java.util.*;
class SimpleInterest {
 int p, t;
 float si, r;
 public si() {
  r = 0;
  p = 0;
 }
 public void getdata() {
  Scanner sc = new Scanner(System.in);
  System.out.println("Enter principle : ");
  p = sc.nextInt();
  System.out.println("Enter rate : ");
  r = sc.nextFloat();
  System.out.println("Enter time period : ");
  t = sc.nextInt();
 }

public void cal() {
  si = (p * r * t) / 100;
 }
 public void display() {
  System.out.println("Principle : Rs" + p);
  System.out.println("Rate : " + r);
  System.out.println("Time period : " + t);
  System.out.println("Simple Interest : Rs" + si);
 }
 public static void main(String args[]) {
  si s = new si();
  s.getdata();
  s.cal();
  s.display();
 }
}


Java Resources are available for Download from below

Category: , , ,

0 comments