Computer Applications
The time period of a Simple Pendulum is given by the formula:
T = 2π√(l/g)
Write a program to calculate the time period of a Simple Pendulum by taking length and acceleration due to gravity (g) as inputs.
Java
Input in Java
313 Likes
Answer
import java.util.Scanner;
public class KboatSimplePendulum
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter length: ");
double l = in.nextDouble();
System.out.print("Enter g: ");
double g = in.nextDouble();
double t = 2 * (22.0 / 7.0) * Math.sqrt(l/g);
System.out.println("T = " + t);
}
}Variable Description Table
Program Explanation
Output

Answered By
158 Likes
Related Questions
What are the different types of errors that take place during the execution of a program?
Distinguish between Testing and Debugging
Write a program by using class 'Employee' to accept Basic Pay of an employee. Calculate the allowances/deductions as given below.
Allowance / Deduction Rate Dearness Allowance (DA) 30% of Basic Pay House Rent Allowance (HRA) 15% of Basic Pay Provident Fund (PF) 12.5% of Basic Pay Finally, find and print the Gross and Net pay.
Gross Pay = Basic Pay + Dearness Allowance + House Rent Allowance
Net Pay = Gross Pay - Provident FundA shopkeeper offers 10% discount on the printed price of a Digital Camera. However, a customer has to pay 6% GST on the remaining amount. Write a program in Java to calculate the amount to be paid by the customer taking printed price as an input.