I am a total beginer and I have to write following program:
"Write a a timezone converter "TimezoneConversion,java". The program should query the following:
1. The time to convert, as double with format hh, mm (for example, 14:30 = 14.30)
2. The time zone code of the origin time zone in short form, e.g. CET
3. The time zone code of the destination time zone
Example output: 14:45 Uhr in CET (UTC+1) is 21:45 Uhr in HKT (UTC+8)
After the user input and the output, the program should start again from the beginning. If the user enters "END" at the time, the program should end.
If the user enters a non-existent (unknown) timezone code, the program should issue an error message and the input of the time zone code must be repeated. The time should be between 00.00 (00:00 o'clock) and 23,59 (23:59 o'clock). If entered other Values, the input of the time must be repeated.
Be sure to implement the following method:
static double convertToTimezone(double time, String fromZone, String toZone)
Time zones (simplified):
AMT (Amazon Time), WGT (West Greenland Time) = UTC-3
ACST (Australian Central Standard Time) = UTC+9:30
CAT (Central Africa Time), EET (Eastern European Time) = UTC+2
CET (Central European Time) = UTC+1
HKT (Hongkong Time), SGT (Singapore Time) = UTC+8
JST (Japan Standard Time) =UTC+9"
As I said I am a total beginer and need urgent someone who can help me with the task. We are not allowed to import something (except the BufferedReader)!
This is what I have done (not much because I don't now how to progress):
I would make a method that for each timezone returns the time difference to UTC. For instance:
Now, if you have a time and a fromZone, then calculate the time according to UTC with this method, and then calculate the requested time, again with this method. This is what I would do in the method 'convertToTimezone'.
Follow Carey's advice. Be careful though: if you have a time like 14.55 and you need to add 2.30, what would be the result?
There are three kinds of actuaries: those who can count, and those who can't.
Happily living in the valley of the dried frogs with a few tiny ads.