Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 381
  • Last Modified:

Problem doing math in JAVA

I have created a program in java. Now my problem here is that I can't figure out how to display the time in mins.

For example I have 197 mins

The output is suspose to be

You worked 3 hours and 17 mins.

Now I got the 3 hours part but I can't seem to figure out how to show the mins. Its like my program has done the math but hasn't displayed the remainder
import javax.swing.JOptionPane;
import java.util.Scanner;
public class time
{
	public static void main(String[] args)
	{

		int timeInMinutes = 197;          
		JOptionPane.showMessageDialog(null, "If you work " + timeInMinutes + " minutes. ");
		JOptionPane.showMessageDialog
			(null, "You have worked " + timeInMinutes/60 + " hours. ");
				
	}
}

Open in new window

0
sobeservices2
Asked:
sobeservices2
  • 4
  • 3
1 Solution
 
cmalakarCommented:
JOptionPane.showMessageDialog
                  (null, "You have worked " + timeInMinutes/60 + " hours and   " + timeInMintues%60 + " minutes");
0
 
sobeservices2Author Commented:
It produced this error couldn't find symbol %

time.java:11: cannot find symbol
symbol  : variable timeInMintues
location: class time
                  (null, "You have worked " + timeInMinutes/60 + " hours and   " + timeInMintues%60 + " minutes");
                                                                                   ^
1 error
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
cmalakarCommented:
There was a typo ;-)
Use this.

JOptionPane.showMessageDialog
                  (null, "You have worked " + timeInMinutes/60 + " hours and   " + timeInMinutes%60 + " minutes")
0
 
sobeservices2Author Commented:
This is sorta fun compaired to unix shell scripting which kicked me in the ass.

Thank you could you explain the null part ?
0
 
sobeservices2Author Commented:
forgot the ; at the end od that line but I figured that out thanks
0
 
cmalakarCommented:
;-)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now