Computer Applications
Write a Java program to obtain principal amount, rate of interest and time from user and compute simple interest.
Answer
import java.util.Scanner;
public class KboatSimpleInterest
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter principal: ");
double p = in.nextDouble();
System.out.print("Enter rate: ");
double r = in.nextDouble();
System.out.print("Enter time: ");
int t = in.nextInt();
double si = p * r * t / 100;
System.out.println("Simple Interest: " + si);
}
}Output
Related Questions
Identify the operator that gets the highest precedence while evaluating the given expression:
a + b % c * d - e
- +
- %
- -
- *
A student executes the following code to increase the value of a variable ‘x’ by 2.
He has written the following statement, which is incorrect.
x = +2;What will be the correct statement?
A. x +=2;
B. x =2;
C. x = x +2;- Only A
- Only C
- All the three
- Both A and C
if (a>b&&b>c) then largest number is:
- b
- c
- a
- wrong expression