Write a simple Java application which calculates the cutoff frequency in a simpl
ID: 3529043 • Letter: W
Question
Write a simple Java application which calculates the cutoff frequency in a simple RC circuit. Your application should ask the user to enter the capacitor and resistor values of the circuit. You must use the JOptionPane class to collect the user's input. The capacitor and resistor values should be treated as floating point values. Calculate the cutoff frequency in hertz: freq = 1 / (2 * pi * capacitor (in farads) * resistor (in ohms)). You must use the JOptionPane class to output the result. Your output must show two digits after the decimal point and contain explanatory text. Make sure you remember to import what your program will use.
Explanation / Answer
import javax.swing.JOptionPane;
public class RC {
private static float cap,res,freq;
public static void main(String[] args){
cap = Float.parseFloat(JOptionPane.showInputDialog(null,"Enter the capacitance value(in farads)"));
res = Float.parseFloat(JOptionPane.showInputDialog(null,"Enter the resistance value(in ohms)"));
freq = (float) (1 / (2 * Math.PI * cap * res));
JOptionPane.showMessageDialog(null,"cutoff frequency in hertz: freq = 1 / (2 * pi * capacitor (in farads) * resistor (in ohms)) = "+Float.toString(freq) );
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.