English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Hello, I am making a program with Dr. Java 5.1. It is a time conversion program. It converts the time from minutes to hours:minutes. The only problem is, I have no idea how to do the equation. Here is my program so far:

import java.util.Scanner;

public class TimeCoversionArthurYanthar {

static Scanner sc = new Scanner (System.in);

public static void main (String [] args) {

//Integers
int mtime;
int htime;
int hour = 12;
int minute = 60;

System.out.println("Enter the time in minutes: ");
int entertime = sc.nextInt();

htime = entertime % hour;
mtime = (entertime - hour) * minute;

System.out.println("The time is: " + htime + ":" + mtime + "");

}
}

2007-10-09 00:08:44 · 4 answers · asked by Anonymous in Computers & Internet Programming & Design

4 answers

You came close.
Use:
htime = entertime / hour;

and
mtime = entertime % hour;
OR
mtime = entertime - (htime * minute);

2007-10-09 22:55:18 · answer #1 · answered by oldguy 4 · 1 0

Age-bigotry is difficulty-loose contained in the US, too. I haven't any thank you to study the two, in case you learn some thing, it extremely is an training--whether it is not formal. maximum training is, extremely, not formal training. right here is my suggestion, based what you have published. whether or not you ever get a job from it, studying Java--or something new, for that rely--will help you reside mentally youthful. Even probably trivial issues like picking a distinctive thank you to return and forth to and from errands each and every day has been shown to extend alertness. With odds stacked against you, it is unwise to take a position particularly some money on a hazard. there are a number of loose aspects, and in case you may not get to first-value skills with those, plus some time and capability, the percentages of having a job are narrow. do not spend your meal money on a lottery value tag! for the reason which you have not any stepped forward formal training (it may be fairly outdated, besides, in case you had a 1980's degree) and no paid journey, some unpaid journey is will in all likelihood be required. locate an open-source venture and commence gaining knowledge of a thank you to acquire source code, acquire and deploy added progression strategies used to construct the venture, and effectively build and run a version of the code thoroughly from source. in case you additionally could make significant contributions to a serious venture, this may be a resumé merchandise and interview factor to apply in lieu of paid paintings journey. you will could venture and show the capability it extremely is predicted of a twenty-some thing for an get right of entry to-point place.

2016-10-06 08:58:28 · answer #2 · answered by ? 4 · 0 0

Start with an example.
60
Now what will the answer be?
I am expecting it to be 1 hour.
Now how did you get this answer?

Now another example
61
This should be 1 hour and 01 minutes.

Now the last example
780
What time will this be? If I have not understood what you are supposed to be doing then I am sorry.

Work out how to do this and you will know what your program will do.

2007-10-09 00:52:47 · answer #3 · answered by AnalProgrammer 7 · 0 0

You don't need to use any equations there are a class in java called SimpleDateFormatter you can use

String inTime = "70";
SimpleDateFormat sdf = new SimpleDateFormat("mm");
try
{
java.util.Date d = sdf.parse(inTime);
sdf.applyPattern("HH:mm");
System.out.println(sdf.format(d));
sdf.applyPattern("HH");
System.out.println(sdf.format(d));
sdf.applyPattern("mm");
System.out.println(sdf.format(d));}
catch(Exception e)
{
e.printStackTrace();
}

In this line you specify the format of the input
SimpleDateFormat sdf = new SimpleDateFormat("mm");
mm : minutes

2007-10-09 00:54:13 · answer #4 · answered by RO86 2 · 0 0

fedest.com, questions and answers