473,411 Members | 2,009 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Anyone for a small Java challenge?


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 5126
> 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
On Fri, 20 Feb 2004 01:41:43 -0500, "Hugh Bothwell" wrote:

<sniplet>
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 how
do you use them? In what way would writing a
program 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 about
as 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
nos
awk '{print int($1 * 29.97);}' < numbers.txt
"Dr. Mercury" <wh@ts.up.doc> 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
"Dr. Mercury" <wh@ts.up.doc> wrote in message
news:ap********************************@4ax.com...
On Fri, 20 Feb 2004 01:41:43 -0500, "Hugh Bothwell" wrote:

<sniplet>
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 how
do you use them? In what way would writing a
program 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 about
as 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
"Hugh Bothwell" <hu***********@hotmail.com> wrote in message news:<qV*******************@nntp-post.primus.ca>...
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
On 20 Feb 2004 18:01:57 -0800, aa*********@sendit.nodak.edu (Aaron)
wrote:

<sniplet>
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.


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
SPC
something like this:

Input numberes in a File1
-Open File1
- Input numbers.
-Close File1
And
-Open File2
- Open File1
- Copy File1 into File2
- Close File1
-Close File2

Sorry, if I misunderstand.
S.P.C

Code:
package Chapters;

import java.io.*;

public class Chapter {

private static String sLine;
private static PrintWriter FileCopy;
private static BufferedReader stdin = new BufferedReader( new
InputStreamReader( System.in ) );

public static void main (String[] args) throws IOException {

Convert() ;
File();

}//fin Main

private static void Convert() throws IOException {

int n=3; //Take 3 inputs
double d;
System.out.print("Enter your list of values:");

FileCopy = new PrintWriter(new FileOutputStream("Test.txt"));

for (int i= 0; i < n ; i++ ){
d = Double.parseDouble(stdin.readLine());
d = (short)(d * 29.97); // 4165.83 --> 4165.0

System.out.println((int)d); //4165.0 --> 4165
FileCopy.println((int)d);

}
FileCopy.close(); //Close Write File : Copy.txt

}//Fin Convert()

private static void File() throws IOException {

BufferedReader FileRead;

FileCopy = new PrintWriter(new FileOutputStream("Copy.txt"));
FileRead = new BufferedReader(new FileReader("Test.txt"));

//Read file "Text.txt" and Copy it in "Copy.tx"t
while ( (sLine = FileRead.readLine()) != null) {
FileCopy.println(sLine);

} //Fin while

FileRead.close(); //Close Read File : Test.txt
FileCopy.close(); //Close Write File : Copy.txt

} // Fin File()

}//Fin Class



"Dr. Mercury" <wh@ts.up.doc> a écrit dans le message de
news:lg********************************@4ax.com...
On 20 Feb 2004 18:01:57 -0800, aa*********@sendit.nodak.edu (Aaron)
wrote:

<sniplet>
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.


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 #8
On Sun, 22 Feb 2004 19:46:54 -0500, "SPC" <he**@sayimpossible.ca.tc>
wrote:
something like this: Input numbers in a File1


<snip>

Thanks very much for the interesting script. Can you give me a brief
rundown on how to use it? I have the general idea, but I could use
some specifics.

Thanks much,
Doc

Jul 17 '05 #9
SPC
Are you talking about" Input numbers" by ?? Math.random() ?? and multi
with 29.97 .
And you want the result in Integer (decimal dropped).
You see the example below,

SPC.
//*************
Ex:
int d ;

d = (int)( Math.random()*29.97 ); // (int) : (decimal dropped).
//this give you ONE number by Random, multi it with 29.97 and convert it in
Integer.

//**********
PS: Sorry, English is not my 1st lan.
"Dr. Mercury" <wh@ts.up.doc> a écrit dans le message de
news:nl********************************@4ax.com...
On Sun, 22 Feb 2004 19:46:54 -0500, "SPC" <he**@sayimpossible.ca.tc>
wrote:
something like this:

Input numbers in a File1


<snip>

Thanks very much for the interesting script. Can you give me a brief
rundown on how to use it? I have the general idea, but I could use
some specifics.

Thanks much,
Doc

Jul 17 '05 #10
On Mon, 23 Feb 2004 20:21:13 -0500, "SPC" <he**@sayimpossible.ca.tc>
wrote:
Are you talking about" Input numbers" by ?? Math.random() ?? and multi
with 29.97 .
And you want the result in Integer (decimal dropped).


Actually, the decimal doesn't have to be dropped. The program the
numbers go into is very 'sensitive' and I didn't want to confuse it
with decimals places, but it seems to just ignore them. So all I want
is something to multiply a list of numbers and produce a new list. If
you could write up a script and tell me how to use it, it would
certainly be appreciated.

Thanks,
Doc

Jul 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

73
by: RobertMaas | last post by:
After many years of using LISP, I'm taking a class in Java and finding the two roughly comparable in some ways and very different in other ways. Each has a decent size library of useful utilities...
54
by: Spammay Blockay | last post by:
I've been tasked with doing technical interviews at my company, and I have generally ask a range of OO, Java, and "good programming technique" concepts. However, one of my favorite exercises I...
5
by: Jeppe | last post by:
Hi @ll, I'm investigating the possibility to call a struts action on a web environment from a standalone java application. I need to make this call automatically, from a crontab (on unix)....
2
by: Dave Brueck | last post by:
Below is some information I collected from a *small* project in which I wrote a Python version of a Java application. I share this info only as a data point (rather than trying to say this data...
15
by: Brandon J. Van Every | last post by:
Is anyone using Python for .NET? I mean Brian's version at Zope, which simply accesses .NET in a one-way fashion from Python. http://www.zope.org/Members/Brian/PythonNet Not the experimental...
47
by: Alan Brown | last post by:
As a newbie I would like to ask what the difference in application (not details) is between C++ and Java. In what situations would you use C++ in preference to Java and vice versa? I am not...
8
by: Mike S | last post by:
Hi all, I noticed a very slight logic error in the solution to K&R Exercise 1-22 on the the CLC-Wiki, located at http://www.clc-wiki.net/wiki/KR2_Exercise_1-22 The exercise reads as...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.