I could pare to Integer, so I have to used double in this code. Is there anyone can help on that please. Also can someone check on modulus formula it seems not working right.Please Help
import java.awt.*; import java.awt.event.*; import javax.swing.*; /** * Sample application using Frame. * * @author * @version 1.00 11/06/19 */ public class HomeWork6Frame extends JFrame { //Creating the Labels private JLabel SecondsL, MinutesL, HoursL, DaysL, YearsL; //L stand for Label //Creating the TextField private JTextField SecondsTF, MinutesTF, HoursTF, DaysTF, YearsTF;//TF stand for TextField //Creating the Buttons private JButton calculate, exit; //Decalring actionlistener for the buttons private CalculateButtonHandler cbHandler; private ExitButtonHandler ebHandler; public HomeWork6Frame() { // The lables part of the program setTitle("Program to Conver Seconds into Minutes,Hours and Days"); SecondsL = new JLabel("Number of Seconds to be convert it: ", SwingConstants.RIGHT); MinutesL = new JLabel("Number of Minuts: ", SwingConstants.RIGHT); HoursL = new JLabel("Number of Hours: ", SwingConstants.RIGHT); DaysL = new JLabel("Number of Days: ", SwingConstants.RIGHT); YearsL = new JLabel("Number of Years: ", SwingConstants.RIGHT); //Text Field protion tf the program SecondsTF = new JTextField(10); MinutesTF = new JTextField(10); HoursTF = new JTextField(10); DaysTF = new JTextField(10); YearsTF = new JTextField(10); // Creating the Buttons calculate = new JButton("Calculate"); cbHandler = new CalculateButtonHandler(); calculate.addActionListener(cbHandler); exit = new JButton("Exit"); ebHandler = new ExitButtonHandler(); exit.addActionListener(ebHandler); //Container portion of the prog Container pane = getContentPane(); pane.setLayout(new GridLayout(7, 2)); //Addin Labels and TextField to the pane pane.add(SecondsL); pane.add(SecondsTF); pane.add(YearsL); pane.add(YearsTF); pane.add(DaysL); pane.add(DaysTF); pane.add(HoursL); pane.add(HoursTF); pane.add(MinutesL); pane.add(MinutesTF); //Adding the Buttons pane.add(calculate); pane.add(exit); //Windows size and visibility setSize(new Dimension(400, 300)); setVisible(true); } /** * Shutdown procedure when run as an application. */ protected void windowClosed() { System.exit(0); } /********************************************************** ********** Calculate class ******************************/ private class CalculateButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { //Declaring Variables double seconds; double minutes = 60; //seconds double hours = 3600;//seconds double days = 86400; //seconds double years = 365; //double temp; // Perofimng the calculations seconds = Double.parseDouble(SecondsTF.getText()); minutes = seconds/minutes; seconds = seconds % minutes; hours = seconds / hours; seconds = seconds % hours; days = seconds / days; seconds = seconds % days; years = seconds / years; seconds = seconds % years; MinutesTF.setText("" + minutes); HoursTF.setText("" + hours); DaysTF.setText("" + days); YearsTF.setText("" + years); } } /********************************************************* ********** Exit class***********************************/ private class ExitButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { System.exit(0); } } }