424,949 Members | 1,063 Online
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

# Anyone for a small Java challenge?

 P: n/a Greetings to all - Someone suggested that Java might be the answer for a little conversion program I need. It's pretty simple, really. Just take a column of numbers: 139 259 433 637 799 1053 1185 and multiply them all by the same number, and spit out a new column. I'm multipilying by "29.97" in this case. I'm trying to convert a column of video times to frames. That would end up looking like: 4165.83 7762.23 12977.01 (etc) although I'd like the decimal dropped, so it ends up looking like: 4165 7762 12977 (etc) Can anyone help me out? Thanks much, Dr. Merc Jul 17 '05 #1
10 Replies

 P: n/a > Someone suggested that Java might be the answer for a little conversion program I need. It's pretty simple, really. Just take a column of numbers: 139 259 433 637 799 1053 1185 and multiply them all by the same number, and spit out a new column. I'm multipilying by "29.97" in this case. I'm trying to convert a column of video times to frames. That would end up looking like: 4165.83 7762.23 12977.01 (etc) although I'd like the decimal dropped, so it ends up looking like: 4165 7762 12977 (etc) Sounds like a job for Excel... how often do you plan to do this? Where do you get the column of numbers, and how do you use them? In what way would writing a program be easier than using a calculator? For starts, see below - this is about as simple as it gets: import java.io.*; import java.lang.Math; import java.lang.Double; public class Convertor { private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) ); public static void main(String[] args) { double d; System.out.println("Enter your list of values:"); while (true) { d = Double.parseDouble(stdin.readLine()); System.out.println( Math.floor( d * 29.97) ); } } } Jul 17 '05 #2

 P: n/a On Fri, 20 Feb 2004 01:41:43 -0500, "Hugh Bothwell" wrote: although I'd like the decimal dropped, so it ends up looking like: 4165 7762 12977 (etc) Sounds like a job for Excel... Howdy, Hugh, thanks for the reply. It works fine in Excel, but I need this as part of a video procedure on my Web site, so it should be something freeware. how often do you plan to do this?Where do you get the column of numbers, and howdo you use them? In what way would writing aprogram be easier than using a calculator? It's a matter of retaining the chapter points in an SVCD when converting to another format. The chapter points can be extracted as times, but the conversion program wants them as frames. Ergo, I need to be able to multiply a column of numbers by either 23.976 or 29.97 (frame rate of the movie depending) to convert the times to frames. A calculator would work, certainly, but it'd be a tad laborious for 20 or so entries. For starts, see below - this is aboutas simple as it gets: Note the small font mismatch below: public static void main(String[] args) { If you could fix that, and let me know how to use the script, it'd be appreciated. I honestly don't know anything about Javascripts except that occasionally I use a chunk of them in my Web pages, like to pre-load dynamic icons. I don't have any idea how to run an independent script like this one. Thanks for the help, Doc -- For all of your DVD/SVCD/DIVX/OGM needs: www.svcd.cc New to DVD recording? www.svcd.cc/dvdrinfo.htm VCD FAQ: http://abvcd.home.comcast.net/FAQ/abvcdfaq5.01.htm SVCD Charter: www.svcd.cc/charter.htm Jul 17 '05 #3

 P: n/a awk '{print int(\$1 * 29.97);}' < numbers.txt "Dr. Mercury" wrote in message news:67********************************@4ax.com... Greetings to all - Someone suggested that Java might be the answer for a little conversion program I need. It's pretty simple, really. Just take a column of numbers: 139 259 433 637 799 1053 1185 and multiply them all by the same number, and spit out a new column. I'm multipilying by "29.97" in this case. I'm trying to convert a column of video times to frames. That would end up looking like: 4165.83 7762.23 12977.01 (etc) although I'd like the decimal dropped, so it ends up looking like: 4165 7762 12977 (etc) Can anyone help me out? Thanks much, Dr. Merc Jul 17 '05 #4

 P: n/a "Dr. Mercury" wrote in message news:ap********************************@4ax.com... On Fri, 20 Feb 2004 01:41:43 -0500, "Hugh Bothwell" wrote: although I'd like the decimal dropped, so it ends up looking like: 4165 7762 12977 (etc)Sounds like a job for Excel... Howdy, Hugh, thanks for the reply. It works fine in Excel, but I need this as part of a video procedure on my Web site, so it should be something freeware.how often do you plan to do this?Where do you get the column of numbers, and howdo you use them? In what way would writing aprogram be easier than using a calculator? It's a matter of retaining the chapter points in an SVCD when converting to another format. The chapter points can be extracted as times, but the conversion program wants them as frames. Ergo, I need to be able to multiply a column of numbers by either 23.976 or 29.97 (frame rate of the movie depending) to convert the times to frames. A calculator would work, certainly, but it'd be a tad laborious for 20 or so entries.For starts, see below - this is aboutas simple as it gets: Note the small font mismatch below: public static void main(String[] args) { If you could fix that, and let me know how to use the script, it'd be appreciated. I honestly don't know anything about Javascripts except that occasionally I use a chunk of them in my Web pages, like to pre-load dynamic icons. I don't have any idea how to run an independent script like this one. Thanks for the help, Doc That's Java. It's what you asked for. It's not javascript or "a script" at all. It's a Java program. See the Java Tutorial: http://java.sun.com/docs/books/tutorial/ Specifically, pay attention to "Your First Cup of Java". Jul 17 '05 #5

 P: n/a "Hugh Bothwell" wrote in message news:... Someone suggested that Java might be the answer for a little conversion program I need. It's pretty simple, really. Just take a column of numbers: 139 259 433 637 799 1053 1185 and multiply them all by the same number, and spit out a new column. I'm multipilying by "29.97" in this case. I'm trying to convert a column of video times to frames. That would end up looking like: 4165.83 7762.23 12977.01 (etc) although I'd like the decimal dropped, so it ends up looking like: 4165 7762 12977 (etc) Sounds like a job for Excel... how often do you plan to do this? Where do you get the column of numbers, and how do you use them? In what way would writing a program be easier than using a calculator? For starts, see below - this is about as simple as it gets: import java.io.*; import java.lang.Math; import java.lang.Double; public class Convertor { private static BufferedReader stdin = new BufferedReader( new InputStreamReader( System.in ) ); public static void main(String[] args) { double d; System.out.println("Enter your list of values:"); while (true) { d = Double.parseDouble(stdin.readLine()); System.out.println( Math.floor( d * 29.97) ); } } } Are you going to have a text file to input these numbers, and then output them in another text file? I could write that, just let me know. Aaron Jul 17 '05 #6

 P: n/a On 20 Feb 2004 18:01:57 -0800, aa*********@sendit.nodak.edu (Aaron) wrote: Are you going to have a text file to input these numbers, and thenoutput them in another text file?I could write that, just let me know. Yep, that's the idea. "chapters.txt" would be converted to "chapters2.txt". Any help with this, and how to run it, would certainly be appreciated. Doc Jul 17 '05 #7