Please help! converting c++ into java
Thanks to the people who helped me with my last bit of text - greatly appreciated, i need a bit more help though, with calculating a basic similarity matrix and clustering. Here is what i have........
void CalcBasicSimMatrix(int nEnt, int nAtt, Entity EAM[], double BSM [100][100]) //problem here*
for (int i=0; i<nEnt; i++)
for (int j=0; j<nEnt; j++)
BSM[i][j]=BasicSimBetweenEnt(i, j, nAtt, EAM); //problem here*
double BasicSimBetweenEnt(i, j, nAtt, EAM); //problem here*
double a=0, t=0;
for (int i=0; i<nAtt; i++)
if(AT[n].Attribute==1 && AT[m].Attribute[i]==1)//problem here*
a++;
else
t++;
return a/(a+t); // is this same in java?
struct Cluster
int ent[100];
int n;
cluster Clusters[100]; //?
void initialiseClusters() //?
nClusters=0;
for(int k=0; k<nEntities; k++)
Clusters[k].n=1; //?
Clusters[k].ent[0]=k; //?
nClusters++;
void PerformClustering() //?
int method;
double SimThreshold;
max=100;
InitialiseClusters(); //?
cout<<"Enter clustering method(1=Ave Link, 2=Min Link, 3=Max Linkage):";
cin>>method;
cout<<"Enter similarity threshold(enter '0' if none required):";
cin>>SimThreshold;
while(nClusters>0 && max>0 && max>SimThreshold)
MostSimilarClusters(method);
if(nClusters>1)
MergeClusters(x,y);
The code for merging clusters also makes no sense...............
Any help is greatfully received.Thanks.
Now, I am assuming you are trying to learn Java, but have also been a C++ user. Here are some questions I need to ask:
Is there a C++ course in Ojbect-Oriented Programming offered to where you are?
What is this code suppose to do?
What parameters does it accept?
What are the return values?
Is this is a recursion part of code for something larger?
Similar Messages
-
Converted WSDL into .java-files - and now?
I should implement a client for an existing web service. All I have is a .wsdl-file of the web service to call.
Therefore I used the eclipse's functionality to convert .wsdl into .java files, which generated some files for me, for example:
- interface XXX extending java.rmi.Remote
- interface XXXService extends javax.xml.rpc.Service
- class XXXProxy implements XXX
- class XXXServiceLocator extends org.apache.axis.client.Service
- class XXXSoapBindingStub extends org.apache.axis.client.Stub implements XXX
- class XXXRfcException extends org.apache.axis.AxisFault implements java.io.Serializable
- class XXXRfcExceptions implements java.io.Serializable
My question... what to do now? How can I get the service and call its functionality?
Your help is really, REALLY appreciated...Hi,
Write client application like below.
public class Client{
public static void main(String [] args) throws Exception {
// Make a service
XXXService service = new XXXServiceLocator();
// Now use the service to get a stub which implements the SDI.
AddressBook port = service.getAddressBook();
// Make the actual call
Address address = new Address(...);
port.addEntry("Russell Butek", address);
Thanks&Regards,
M.Kumaraswamy. -
Please help me with these java puzzle ?
Dear all,
My friend send me typical java puzzle about java.util.ArrayList
which is getting messy. Please help me out. It's not a homework.
Please help me with these java puzzle ?
Dear all,
My friend send me typical java puzzle about java.util.ArrayList
which is getting messy. Please help me out. It's not a homework.
import java.util.*;
public class MyInt ______ ________ {
public static void main(String[] args) {
ArrayList<MyInt> list = new ArrayList<MyInt>();
list.add(new MyInt(2));
list.add(new MyInt(1));
Collections.sort(list);
System.out.println(list);
private int i;
public MyInt(int i) { this.i = i; }
public String toString() { return Integer.toString(i); }
________ int ___________ {
MyInt i2 = (MyInt)o;
return ________;
}Hints , fill the underlines with below :
implements
extends
Sortable
Object
Comparable
protected
public
i = i2.i
i
i2.i=i
compare(MyInt o, MyInt i2)
compare(Object o, Object i2)
sort(Object o) sort(MyInt o)
compareTo(MyInt o)
compareTo(Object o)Dear all,
My friend send me typical java puzzle aboutNotwithstanding your pathetic protestations typicial
of all your posts this is NOT a typical java "puzzle"
but is indeed a typical homework puzzle.
And it's damn easy if you spent 30 minutes with a
tutorial.
DO YOUR OWN HOMEWORK!
Hey i did it.
import java.util.*;
public class MyInt implements Comparable {
public static void main(String[] args) {
ArrayList<MyInt> list = new ArrayList<MyInt>();
list.add(new MyInt(2));
list.add(new MyInt(1));
Collections.sort(list);
System.out.println(list);
private int i;
public MyInt(int i) { this.i = i; }
public String toString() { return Integer.toString(i); }
public int compareTo(Object o){
MyInt i2 = (MyInt)o;
return i;
}E:\>javac MyInt.java
Note: MyInt.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
E:\>java MyInt
[1, 2] -
Converting flash into java script - please help!
Our site uses a lot of flash text and flash images, I have
been told by a friend of a friend that i need to change the way
flash is embedded into java script - i only know the basics of web
design and this is me hitting brick wall!
Maybe someone could help point me in the right direction -
simply! thank you in advance!!!!!!!!!!!!!!!!!!!!!!!!!!which version of dw do you have?
for background info, google EOLAS activeX lawsuit
Alan
Adobe Community Expert, dreamweaver
http://www.adobe.com/communities/experts/ -
Please help with combining two java packages into one iteration
Hello, I work for a pharmaceutical company and run reports for credits that we have received. Currently the packages are reported seperately from the credit reports and my job is to combine them. There are two models that handle these and I need to link the second to the first with some common entities. Please help me figure out what I need to do in order to add a credit column to the report. I have a sample of the code below and would appreciate any help you can offer.
First, the info pulled about the boxes:
rm = (ReportManager) ManagerFactory.getManager(ManagerFactory.REPORTS);
items = rm.getRVSSearchResults(hvstoresid,
hvstoregroupsid,
String.valueOf(request.getParameter("price_type")).trim(),
String.valueOf(report_by).trim(),
vendor_type,
String.valueOf(request.getParameter("vendor")).trim(),
from_date,
until_date,
debitNum,
processing_type,
sort_field,
sort_direction,
includeAll222s).iterator();
Second, the page that has the data i need to transpose to the first:
PackoutModel pm = null;
int iter = searchpageposition*resultPageSize;
while (iter < packouts.size() && iter<(searchpageposition*resultPageSize)+resultPageSize)
{ pm = (PackoutModel) packouts.get(iter);
BigDecimal invoiceAmt = DataConverter.parseBigDecimalWithAlternateWhenNull(pm.getInvoiceAmt(),"0.00");
BigDecimal creditRec = DataConverter.parseBigDecimalWithAlternateWhenNull(pm.getAmtReceived(),"0.00");
BigDecimal processingFee = DataConverter.parseBigDecimalWithAlternateWhenNull(pm.getProcessFeeTotal(),"0.00");
BigDecimal shippingFee = DataConverter.parseBigDecimalWithAlternateWhenNull(pm.getShippingHandlingFeeTotal(),"0.00");
BigDecimal balanceDue =(invoiceAmt.add(processingFee.add(shippingFee))).subtract(creditRec);
All that I need from the second page is to get a value for:
DataConverter.parseBigDecimalWithAlternateWhenNull(pm.getAmtReceived(),"0.00");
which I believe must first have the store id, etc equal to the first model. So there is the existing rvs.FOO and the needed pm.BAR but since it is in an iter loop, I can't seem to figure out how to join the two.
Any ideas?could you explain your problem with a simplified schema or a more
understandable code.
(don't bother to write the details of your project plz) -
Convert string into java.sql.Date
Hi,
I want to convert a date in string form into java.sql.Date to persist into the database column with Date as its datatype in Oracle. I'm trying as follows:
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
public class DateTest
public static void main(String[] args)
String strDate = "2002-07-16 14:45:01";
System.out.println("strDate = "+strDate);
Date aDate = null;
try
if(strDate != null && !strDate.trim().equals(""))
SimpleDateFormat aSDF = new SimpleDateFormat();
aSDF.applyPattern("yyyy-MM-dd hh:mm:ss");
java.util.Date utilDate = aSDF.parse(strDate);
System.out.println("utildate = "+utilDate);
aDate = new Date(utilDate.getTime());
aDate.setTime(utilDate.getTime());
System.out.println("aDate = "+aDate);
catch (ParseException e)
System.out.println("Unable to parse the date - "+strDate);
catch (Exception ex)
ex.printStackTrace();
System.out.println("Caught Exception :"+ex.getMessage());
It gives the output as :
strDate = 2002-07-16 14:45:01
utildate = Tue Jul 16 14:45:01 IST 2002
aDate = 2002-07-16
If I put this value into the database table, I can see only the date. Time part is missing. Is this the problem with java.sql.Date or Oracle datatype Date? Please help me asap.
Thanks in advance.
Regards,
Rajapriya.R.If I put this value into the database table, I can
see only the date. Time part is missing. Is this the
problem with java.sql.Date or Oracle datatype Date?This is not a problem, this is the defined behaviour of the Date type. RTFAPI and have a look at Timestamp, while you're at it. -
Can someone please help me with a java assignment
Hey all,
I have a favor to ask I have a program that I need for my java class, I have the just of it but I can't figure out the rest, can anybody please help me here is the directions:
Let's revisit fibonacci numbers, looking at it as a process involving iteration and arrays. Create an array fib[] of 101 elements. Make fib[0] = 0 and fib[1] = 1. Then, in an iterative process going from 2 to 100, compute fib[k]. These numbers get quite large; make it an array of double.
Then, let the user select a number (such as 7) and have the application display the corresponding finbonacci number (in this case 13). Do this as often as the user wants. If a number larger than 100 is provided, display an error message, but don't terminate the program.
Here is what I have so far: Please add on and feel free to return to me please, thank you:
// This is an application that transforms numbers into their Fibonacci number
import javax.swing.*;
public class Fibonacci {
public static void main( String args[] ){
int k; //simple counter
int numSize; // how many numbers were entered
int theNum; // the number entered by the user
String response; //response of the user
// define the array
double fib[] = new double[ 101 ];
// read in the numbers into an array
k = 0;
response = JOptionPane.showInputDialog( "Enter the first number" );
theNum = Integer.parseInt( response );
while (theNum > 0){
if (theNum > 100)
k++;
fib [ 1 ] = 1;
fib [ 2 ] = 1;
response = JOptionPane.showInputDialog( "Enter the next number, negative to end" );
theNum = Integer.parseInt( response );
} // end while
numSize = k;
// terminate
System.exit( 0 );
}// end main
} //end class FibonacciTry this program..Hope it helps
import javax.swing.*;
public class Fibonacci
static double fib[];
public Fibonacci()
fib = new double[ 101 ];
fib[0] = 0;
fib[1] = 1;
for(int i = 2; i < fib.length; i++)
fib[i] = fib[i -1] + fib[i - 2];
public static void main( String args[] )
boolean end = true;
String response = "";
int theNum = 0;
new Fibonacci();
while(end)
response = JOptionPane.showInputDialog( "Enter the number. 999 to end" );
try
theNum = Integer.parseInt( response );
if(theNum == 999)
end = false;
else if(theNum <101)
String Message = "The Fibonacci number at "+ theNum + " is : "+ fib[theNum - 1];
JOptionPane.showMessageDialog(null, Message, "Fibonacci Number", JOptionPane.INFORMATION_MESSAGE);
else
JOptionPane.showMessageDialog(null, "Input should be less than 100", "Error", JOptionPane.ERROR_MESSAGE);
catch(NumberFormatException ex)
JOptionPane.showMessageDialog(null, "Enter Numeric values", "Error", JOptionPane.ERROR_MESSAGE);
System.exit(0);
}// end main
} //end class FibonacciVish -
Please HELP me with installation - java.lang.noclassdeffounderror:
Please Help! For school we need to install JAVA. I installed JDK 5.0 and id did not work. I got exception in thread "main" java.lang.noclassdeffounderror: hello. I was using Texpad to write, compile, and run it. In short I deleted all JAVA 5.0 using My Computer program removal. I installed JAVA 1.4..2_10 and I am still getting that same error. I want the JAVA 1.4..2_10 to be installed and not JAVA.5.0.
My System Variable CLASSPATH still shows C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip. My System Variable PATH has nothing as far as JAVA in it. MY PATHEXT has JS and JSE amoung other things in it. My System Variable QTJAVA still has Files\Java\jre1.5.0_03\lib\ext\QTJava.zip in it.
Please tell me step-by-step how I can fix this. I never updated these variables before. What do I need to type and where? What do I need to get rid of or change?
PLEASE HELP!
Thanks,
JimI left my System variable classpath --> C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip I left my QT JAVA --> C:\Program Files\Java\jre1.5.0_03\lib\ext\QTJava.zip I added Path --> ;C:\j2sdk1.4.2_10\bin and then restarted my computer. I added hello file in C:\j2sdk1.4.2_10\bin and tried to compile it under a new name and it would not compile. it gave me the error below. I was able to compile other java program in my other folder in a different directory. I am still getting the same error messages/ Anything else I should try? IS there anyplace or person I can call who would come and fix this? Something is wrong. This should not be giving me this much trouble. All The Java directions on other websites tell me to do different things. I am so confused... please help.
I get this during the compilenow:
javac: invalid flag: C:\j2sdk1.4.2_10\bin\helloa.txt
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
-g:none Generate no debugging info
-g:{lines,vars,source} Generate only some debugging info
-nowarn Generate no warnings
-verbose Output messages about what the compiler is doing
-deprecation Output source locations where deprecated APIs are used
-classpath <path> Specify where to find user class files
-sourcepath <path> Specify where to find input source files
-bootclasspath <path> Override location of bootstrap class files
-extdirs <dirs> Override location of installed extensions
-d <directory> Specify where to place generated class files
-encoding <encoding> Specify character encoding used by source files
-source <release> Provide source compatibility with specified release
-target <release> Generate class files for specific VM version
-help Print a synopsis of standard options
Tool completed with exit code 2
Jim
If you can fix this I will give you 14 points. I hope it is enough. I just want this to work for school. -
Please help convert 8.2 vi to 8.0 (urgent)
Hi all,
Could anyone please help me convert the attached vi to labview 8.0. Thanks
Attachments:
Google_Earth-LV.llb 199 KBTry this...
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Google_Earth-LV_80.llb 197 KB -
Please help to upload with java servlet
I want to install a java servlet uploader on my web site and i try to do it many times but i can't beacuse i dont know what are the essentials that should be found on the server to install java servlet in right way ..
so please help me to do this .. and tell me what i need to upload files correctly with java servlet .
any help will be appreciated ..
thank you !Hello newton ..
I only want to know what are the requirments that let me use the java servlet on linux system .. because i want use an uploader using java servlet ..
thank u newton ..
any help will be appreciated -
Please help. Since yesterday whenever i try to use my ipod touch, all the icons won't let me enter the app. Every one whenever i touch it just shows a faint square round the icon, and it won't access the item. Tried re-starting & re-setting but it hasn't fixed it.
Are some of your accessiblity features activated?
Each accessibility feature can be turned on or off in Accessibility settings on iPod touch. You can also turn some features on or off in iTunes when iPod touch is connected to your computer.
Turn on accessibility features using iPod touch: Go to Settings > General > Accessibility.
Turn on accessibility features using iTunes: Connect iPod touch to your computer and select iPod touch in the iTunes device list. Click Summary, then click Configure Universal Access at the bottom of the Summary screen. -
Please Help ( Converting TRL to TRY)
Hi,
My client wants to do a currency conversion, from Old Turkish Lira (TRL) to New Turkish Lira(TRY). Now the thing is the Co. Code currency is still TRL, but they have TRY in their system, and they are maintaining Translation ratios beween TRL and TRY and TRY and other currencies like EUR. Even exchange rates type M are maintained between TRY and USD, and EURX between TRY and EUR.
So my question is how to go ahead with this currency conversion, what more is left for this conversion?
Please Help
SAP FICOHi,
Please go through the Note 731961 - Adding the "New Turkish Lira" currency code TRY.
There is a collective Note: Note 727563 - Collective note for currency conversion in Turkey
Hope these may help you.
Rgds, -
Please help converting filenames
Thanks a lot for your help
I am trying to set the creation date as the new file name in series of files within a folder
I try to modify various scripts I found for my purpose
[applescript]
set source_folder to choose folder with prompt "Please select directory."
set destination to choose folder with prompt "Please select directory."
tell application "Finder"
set file_list to every file of folder source_folder
end tell
tell application "Finder"
launch
try
duplicate source_folder to destination
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try
repeat with aFile in file_list
set file_info to info for (aFile as alias)
set file_creation_date to creation date of file_info
set tPath to quoted form of (POSIX path of aFile)
set tName to name of (info for aFile)
set MD to do shell script "mdls -name kMDItemContentCreationDate " & aFile
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "= ("
set tDates to text item 1 of MD
set AppleScript's text item delimiters to ")"
set tDates to (text item 1 of tDates) as text
set AppleScript's text item delimiters to TID
set dateInfo to text 30 thru -1 of tDates
set newFilename to dateInfo
try
tell application "Finder" to set name of aFile to newFilename
end try
end repeat
end tell
[/applescript]
the error I get is:
Can’t make «class docf» "10 - TXT.doc" of «class cfol» "result" of «class cfol» "newfolder" of «class cfol» "ecco" of «class cfol» "my folder" of «class cfol» "Documents" of «class cfol» "ZZZ" of «class cfol» "Users" of «class sdsk» of application "Finder" into the expected type.OK, to do that you just need to tell the Finder to duplicate the file first (you had originally set a destination folder, but didn't do anything with it) - note that there isn't any error handing (a duplicate file name for example), the script just logs the error:
set source_folder to (choose folder with prompt "Please select source directory.")
set destination to choose folder with prompt "Please select destination directory."
tell application "Finder"
set file_list to every file of folder source_folder as alias list
end tell
repeat with aFile in file_list
set tPath to quoted form of POSIX path of aFile
set newFilename to (do shell script "mdls -name kMDItemContentCreationDate -raw " & tPath)
set TID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ":"
set pieces to text items of newFilename
set AppleScript's text item delimiters to "-"
set newFilename to pieces as text
set AppleScript's text item delimiters to TID
try
tell application "Finder"
set copiedFile to (duplicate aFile to destination)
set name of copiedFile to newFilename
-- set name of copiedFile to text 1 thru 19 of newFilename -- strip off time offset
end tell
on error errorMsg number errorNum
log errorMsg
end try
end repeat
You can find information about the AppleScript language in the AppleScript Language Guide, and an application's scripting dictionary (if it has one) can be opened in the AppleScript Editor to view the additional commands that it provides. -
Please help convert MSSQL Stored Procedure to Oracle PL/SQL
Hi there to all,
this be my first post to these forums. I have already posted this question on a microsoft msdn forum, until someone advised that I ask my question here - dunno why I didnt think of that! ?:|
Im working with an Oracle 10g Database from an ASP.NET 2.0 application, and want to know if it Oracle supports OPENXML (rhetorical question I fear!). The reason I ask is because I want to create an Oracle Stored Procedure that will accept an XML string as an input parameter, prepare it, select from it, and then insert it into an Oracle table.
I have done this successfully in SQL server using the following as an example:
CREATE PROCEDURE [dbo].[Employee_INSERT]
bq. @INSERTRECORD XML
AS
BEGIN
bq. DECLARE @XDOC INT; \\ EXEC sp_xml_preparedocument @XDOC OUTPUT, @INSERTRECORD; \\ INSERT INTO [dbo].[REC_Employees] (
bq. bq. [EMPTITLE], \\ [EMPFNAME], \\ [EMPLNAME], \\ [EMPDEPTID], \\ [EMPBEGINDATE], \\ [EMPACTIVE], \\ [EMPDATEADDED]
bq. )
bq. SELECT
bq. bq. [EMPTITLE] = Title, \\ [EMPFNAME] = Firstname, \\ [EMPLNAME] = LastName, \\ [EMPDEPTID] = DepartmentID, \\ [EMPBEGINDATE] = StartDate, \\ [EMPACTIVE] = IsActive, \\ [EMPDATEADDED] = GETUTCDATE()
bq. FROM
bq. bq. OPENXML(@XDOC, '/EMPREC/Table', 2) \\ WITH (
bq. bq. Title VARCHAR(10), \\ FirstName VARCHAR(50), \\ LastName VARCHAR(50), \\ DepartmentID INT, \\ StartDate DATETIME, \\ IsActive BIT
bq. bq. );
bq. EXEC sp_xml_removedocument @XDOC;
END
I would sincerely appreciate any help in this regard!
PS - Please excuse the formatting!
Much Thanks!
regards
shalanAssuming your table is named DESTINATION
Name Null? Type
TITLE VARCHAR2(10)
FIRSTNAME VARCHAR2(50)
LASTNAME VARCHAR2(50)
DEPARTMENT NUMBER
STARTDATE DATE
ISACTIVE NUMBERYou can use a procedure like:
create or replace
procedure test (p_xml in xmltype)
is
begin
insert into destination
select title
, firstname
, lastname
, department
, to_date (startdate, 'yyyy-dd-mm hh24:mi:ss') startdate
, isactive
from (xmltable ('/EMPREC/Table' passing p_xml
columns title varchar2(5) path 'Title'
, firstname varchar2(10) path 'FirstName'
, lastname varchar2(10) path 'LastName'
, department number path 'Department'
, startdate varchar2(20) path 'StartDate'
, isactive number path 'IsActive'
) temp
end test;to create records in the table
Removed a unnecessary SELECT FROM DUAL...
Edited by: Alex Nuijten on Jan 19, 2009 2:24 PM -
Please help me with two Java problems
Hello,
I have 2 Java problems to work on and wondered if someone can help please?
1. I've created an array, but I have to now create a text file and write a program to read the array from the file. I have no idea where to start the program!
2.public class SumExample1 {
/* To determine if a number lies between 1 and 1000
* @param args the command line arguments
public static void main(String[] args) {
int num;
System.out.print("Enter a number: ");
num = TextIO.getInt();
if ((num >=1) && (num<=1000))
System.out.println("OK");
else
System.out.println ("Not OK");
Ive used a GUI to create some fields and buttons to press. How can I make it perform this little program?
Many thanks,
KI recommend you read the tutorials on basic (file) IO and Swing (and Event Listeners if you want to make your GUI alive). Perhaps have a look at the Scanner class and BufferedInputStream. That should give you enough to start and write the program yourself. Try working in the command prompt first, should be easier, then once the logic works wrap it in a Swing GUI.
You can find the tutorials here:
http://download.oracle.com/javase/tutorial/
Swing:
http://download.oracle.com/javase/tutorial/uiswing/index.html
Basic IO:
http://download.oracle.com/javase/tutorial/essential/io/index.html
Hope this helps.
PR
Maybe you are looking for
-
Failure of duplicate - ORA -06054
Hi, After a backup, we have a duplicate script running to copy it over to other server. Sometimes, when there is extra activity on the db and the backup takes longer, the duplicate fails with this: RMAN-03002: failure of Duplicate Db command at 04/08
-
1. I have a requirement in which I need to show a column values with (lets say A), checkboxes as below CB a1 CB a2 CB a3 CBa4 CB a5 CB a6
-
right here we go.... i have got past all the problems connecting my xp machine to my macbook. but now when i connect my macbook to the xp machine it asks for the username and password as normal but says that the password has expired. The user i have
-
"disk full" error, tried suggestions mentioned here
Hey, My Zen Nano Plus doesn't work properly anymore... When I tried to copy some new files I got a pop-up which said that my disk was full, and according to the properties, it was indeed using all of the 52 MB disk-space. After deleting some 20 songs
-
Former iTunes purchases on a new Mac
Unfortunately, I lost my old MacBook. Now I bought a new MacBook Air and I cannot access the purchases I made from the old one. Therefore I cannot synchronize my iPhone, because the old apps would disappear. I already activated the new computer in iT