Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6090293
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:11:52+00:00 2026-05-23T12:11:52+00:00

I´m totally new to programming in java, and following some basic tutorials for my

  • 0

I´m totally new to programming in java, and following some basic tutorials for my self.
I´m trying to solve an excercise wich tells me to make a small program where the user types in an amonunt of seconds. The program is then supposed to return how many hours, minutes and seconds this is. I can´t get ridd of the error messages. Can anyone help me please?
My code is the following

import javax.swing.JOptionPane;
public class Time2
{
   public static void main( String args[] )
   {
      // Defining types of data:
      String secondstring;
      int minutes;
      int seconds;
      int hours;
      int seconds1;
      int seconds2;

      // Making inputwindow and initializing the variable sekondstring:
      secondstring = JOptionPane.showInputDialog( "Type in seconds!" );

      // Converting secondstring to type int:
      seconds = Integer.parseInt( secondstring );

      // Initializing the variables seconds, minutes and hour:
      hours = seconds / 3600;
      seconds1 = seconds % 3600;
      minutes = seconds1 / 60;
      seconds2 = seconds1 % 60;

      // Making output box:
      JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );

    } // End of main method.
} // End of class Time2

I get the following error-message when I try to compile:

Time2.java:28: ')' expected
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                ^
Time2.java:28: not a statement
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                           ^
Time2.java:28: ';' expected
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                                    ^
Time2.java:28: not a statement
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                                                       ^
Time2.java:28: ';' expected
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                                                               ^
Time2.java:28: not a statement
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                                                                                                 ^
Time2.java:28: ';' expected
    JOptionPane.showMessageDialog( null, "That will be " + hours "hours, " + minutes "minutes, and " + seconds2 "seconds.", "Result", JOptionPane.PLAIN_MESSAGE );
                                                                                                                                                               ^
7 errors
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:11:53+00:00Added an answer on May 23, 2026 at 12:11 pm

    After each of hours, minutes and seconds2 you need to add a + sign before the double quotes.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First and foremost. I'm totally new to programming in Excel. I'm trying to make
I am totally new to programming. I´m reading some tutorials on the internet, and
I'm totally new to GreaseMonkey, but I'm trying to make a little script. //
I am totally new to programming and to some new technologies. Right now I
I am fairly new to Java programming and was following a tutorial located here:
I am totally new in programming. For my first programm I tried to make
I am totally new to math/numerical analysis programming and I was looking all over
I'm totally new to both java and java Server worlds... But I've a good
I'm using Delphi 7, totally new to database programming, and need ODBC. I am
I'm totally new to Ruby but not to programming. All I did was going

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.