Below is a java code that converts seconds, weeks, hours, and minutes. Revise the given code to make a  program that converts years to days, weeks, hours, minutes, and second. Assume that 1 year is 365 days.

New Perspectives on HTML5, CSS3, and JavaScript
6th Edition
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Patrick M. Carey
Chapter3: Designing A Page Layout: Creating A Website For A Chocolatier
Section3.3: Visual Overview: Layout With Positioning Styles
Problem 4QC
icon
Related questions
Question

Below is a java code that converts seconds, weeks, hours, and minutes. Revise the given code to make a  program that converts years to days, weeks, hours, minutes, and second. Assume that 1 year is 365 days.

//Place components in the pane
pane.add(secondsL);
pane. add(secondsTF);
pane, add(yearst);
pane. add(yearsTF);
pane. add (weeksL);
pane. add(weeksTF);
pane, add(daysL);
pane. add(daysTF);
pane. add(hoursL);
pane. add(hoursTE);
pane. add(minutest);
pane. add(minutesTF);
pane. add(calculateB);
pane. add(exitB);
setsize(1280, 800);
setvisible(true);
setDefaultcloseOperation(EXIT ON_CLOSE);
private class CalculateButtontandler implements ActionListener {
public void actionPerformed (ActionEvent e)(
double years, weeks, days, hours, minutes, seconds;
seconds = Double.parseDouble (secondsTF.getText ());
years = (seconds / 31556926);
weeks =(seconds / 604800);
days = (seconds / 86400);
hours = (seconds / 3600);
minutes - (seconds / 60);
private class ExitButtonHandler implements Actionlistener {
public void actionPerformed(ActionEvent e) (
System.exit (0);
public static void main(String[] args) {
secConvert rectobject - new secConvert();
Transcribed Image Text://Place components in the pane pane.add(secondsL); pane. add(secondsTF); pane, add(yearst); pane. add(yearsTF); pane. add (weeksL); pane. add(weeksTF); pane, add(daysL); pane. add(daysTF); pane. add(hoursL); pane. add(hoursTE); pane. add(minutest); pane. add(minutesTF); pane. add(calculateB); pane. add(exitB); setsize(1280, 800); setvisible(true); setDefaultcloseOperation(EXIT ON_CLOSE); private class CalculateButtontandler implements ActionListener { public void actionPerformed (ActionEvent e)( double years, weeks, days, hours, minutes, seconds; seconds = Double.parseDouble (secondsTF.getText ()); years = (seconds / 31556926); weeks =(seconds / 604800); days = (seconds / 86400); hours = (seconds / 3600); minutes - (seconds / 60); private class ExitButtonHandler implements Actionlistener { public void actionPerformed(ActionEvent e) ( System.exit (0); public static void main(String[] args) { secConvert rectobject - new secConvert();
Import javan. swing.
import java.at.
import java.at.event.":
/caloulates seconds into years, weeks, days, hours, and ninutes
public class seccomvert extends Frame {
private Label secondst, yearst, dayst, eekst, hourst, ninutest;
private TextField secondsTF, yearstE, weeksTF, daysTF, hoursTF, ninutesTE;
private 18utton calculatel, exite;
private Calculatetuttonitandler cbitandler;
private Exittuttontandler ebitandler;
public secconvert) (
ICreate labels
settitle("Seconds Converter"),
secondsi - new JLabel("Enter the total number of seconds", Suingconstants.RIGHT),
yearst - new
weeksl- new 3Label("Weeks", Swingtonstants.RIGHT);
daysl - neu JLabel("Days", Suingconstants. RIGHT);
hoursl - new Label("Hours", SwingConstants.RIGHT);
minutest - new ILabel("Hinutes", SuingConstants.RIGHT):
/Create text field
secondsTF- new TextField(10);
yearsTF ne TextField(10),
weeks TE. new 3TextField(10);
daysTE- neu 3Textfield(10);
hoursT- new 3Textfield(10);
inutesTF - ne TextField(10);
/Create calculate button
calculates - new 18utton("Calculate")
eblandler - new CalcviatebuttonHandier(),
calculatel. addactionlistener(cbitandiler);
/Create exit button
exite - new 38utton("Exit");
eblandler- new Exiteuttoritandler();
exito.addictioniistener(ebitandler);
/Set container
Container pane etcontentPane(,
pane, setlayout(new Gridiayout(4, 2))
/Place components in the pane
pane. add(secondsL);
pane.add(secondsTF);
pane, add(yearst);
pane.add(yearsti)
Transcribed Image Text:Import javan. swing. import java.at. import java.at.event.": /caloulates seconds into years, weeks, days, hours, and ninutes public class seccomvert extends Frame { private Label secondst, yearst, dayst, eekst, hourst, ninutest; private TextField secondsTF, yearstE, weeksTF, daysTF, hoursTF, ninutesTE; private 18utton calculatel, exite; private Calculatetuttonitandler cbitandler; private Exittuttontandler ebitandler; public secconvert) ( ICreate labels settitle("Seconds Converter"), secondsi - new JLabel("Enter the total number of seconds", Suingconstants.RIGHT), yearst - new weeksl- new 3Label("Weeks", Swingtonstants.RIGHT); daysl - neu JLabel("Days", Suingconstants. RIGHT); hoursl - new Label("Hours", SwingConstants.RIGHT); minutest - new ILabel("Hinutes", SuingConstants.RIGHT): /Create text field secondsTF- new TextField(10); yearsTF ne TextField(10), weeks TE. new 3TextField(10); daysTE- neu 3Textfield(10); hoursT- new 3Textfield(10); inutesTF - ne TextField(10); /Create calculate button calculates - new 18utton("Calculate") eblandler - new CalcviatebuttonHandier(), calculatel. addactionlistener(cbitandiler); /Create exit button exite - new 38utton("Exit"); eblandler- new Exiteuttoritandler(); exito.addictioniistener(ebitandler); /Set container Container pane etcontentPane(, pane, setlayout(new Gridiayout(4, 2)) /Place components in the pane pane. add(secondsL); pane.add(secondsTF); pane, add(yearst); pane.add(yearsti)
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
New Perspectives on HTML5, CSS3, and JavaScript
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:
9781305503922
Author:
Patrick M. Carey
Publisher:
Cengage Learning