java programming

1. Time Calculator Write a program that asks the user to enter a number of seconds. • There are 60 seconds in a minute. If the number of seconds entered by the user is greater than or equal to 60, the program should display the number of minutes in that many seconds. • There are 3,600 seconds in an hour. If the number of seconds entered by the user is greater than or equal to 3,600, the program should display the number of hours in that many seconds. • There are 86,400 seconds in a day. If the number of seconds entered by the user is greater than or equal to 86,400, the program should display the number of days in that many seconds.

  1. 👍 0
  2. 👎 0
  3. 👁 1,124
  1. ergs

    1. 👍 0
    2. 👎 0
  2. //import java.util.Scanner;
    import javax.swing.JOptionPane;

    public class TimeCalculator
    {
    public static void main(String [] args)
    {

    //variable declarations

    String input;
    double seconds, minutesCalculated, hoursCalculated, daysCalculated;
    final double secondsPerMinute = 60;
    final double secondsPerHour = 3600;
    final double secondsPerDay = 86400;

    input = JOptionPane.showInputDialog("Enter the seconds:");

    if (seconds < secondsPerMinute)
    {
    JOptionPane.showMessageDialog(null, seconds + " seconds (no conversion was made)");
    }

    else if (seconds >= secondsPerMinute && seconds < secondsPerHour )
    {
    minutesCalculated = seconds/secondsPerMinute;
    JOptionPane.showMessageDialog(null, seconds + " seconds equals: " + minutesCalculated + " minutes");
    }

    else if (seconds >= secondsPerHour && seconds < secondsPerDay)
    {
    hoursCalculated = seconds/secondsPerHour;
    JOptionPane.showMessageDialog(null, seconds + " seconds equals: " + hoursCalculated + " hours");
    }

    else if (seconds >= secondsPerDay)
    {
    daysCalculated = seconds/secondsPerDay;
    JOptionPane.showMessageDialog(null, seconds + " seconds equals: " + daysCalculated + " days");
    }

    }

    1. 👍 0
    2. 👎 0

Respond to this Question

First Name

Your Response

Similar Questions

  1. Programming

    Write a pseudocode to represent the logic of a program that allows a user to enter an hourly pay rate and hours worked. The program outputs the user's gross pay

  2. Programming

    Draw a flowchart or write pseudo code to represent the logic of a program that allows the user to enter values for the current year and the user’s birth year. The program outputs the age of the user this year. Preferably a

  3. intro to computer programming

    Write a program that asks the user to enter the number of packages purchased. The program should then display the amount of the discount (if any) and the total amount of the purchase after the discount. Your program should use a

  4. web technology

    write a javascript program that ask the user to enter up to 10 scores golf

  1. Pseudocode

    Write an algorithm and pseudocode that represents a program that allows a user to enter two numbers. Your program should calculate the sum, difference (both directions), product, and quotient (both directions) of the two numbers.

  2. C++

    // Program: name of program // Author: your name // Date Written: date you began writing the program /* Abstract: Brief description of the program */ Include in-line comments in the body of your program. You can convert

  3. CIS

    Draw a flowchart or write pseudocode to represent the logic of a program that allows the user to enter a value. The program multiplies the value by 10 and outputs the result.

  4. Programming Logic and Design (help?)

    Design a retirement planning calculator for Skulling Fincancial Services. Allo a user to enter a number of working years remaining in the user's career and the annual amount of money the user can save. Assume that the user earns

  1. programming logic and design

    I need help writing pseudocode for this problem: Design a retirement planning calculator for skulling financial services • Allow a user enter a number of working years remaining in the user career and the annual amount of money

  2. programming

    Write a program that plays a simple dice game between the computer and the user. It uses an unusual dice that has 12 sides, with numbers that start from 10. When the program runs, a loop should repeat 5 times. Each iteration of

  3. java programming

    Test Average and Grade Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: •

  4. programming

    Write a program which allows user to enter 10 student names and scores for Java programming 1 and Java programming 2. Allow user to choose which course they want to enter the record for. Use the loop to ask input from user. The

You can view more similar questions or ask a new question.