0% found this document useful (0 votes)
3 views2 pages

Java Class -i

Uploaded by

Jeromy R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Java Class -i

Uploaded by

Jeromy R
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Program - Finding Simple Interest using Scanner

Source code:
import java.util.Scanner;

class SimpleInterest {

public static void main(String[] args) {

float p, r, t, si;

Scanner reader = new Scanner(System.in);


System.out.print("Enter principal amount: ");
p = reader.nextFloat();
System.out.print("Enter rate: ");
r = reader.nextFloat();
System.out.print("Enter time period: ");
t = reader.nextFloat();

si = (p*r*t)/100;

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

Output:
Program - Checking Odd or even using if else
Source code:
import java.util.Scanner;
class EvenOdd {
public static void main(String[] args) {
Scanner reader = new Scanner(System.in);
System.out.print("Enter a number: ");
int num = reader.nextInt();

if(num % 2 == 0)
System.out.println(num + " is even");
else
System.out.println(num + " is odd");
}
}

Output:

You might also like