aspose file tools*
The moose likes Beginning Java and the fly likes solve this please Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "solve this please" Watch "solve this please" New topic
Author

solve this please

teja dharma
Ranch Hand

Joined: Feb 07, 2009
Posts: 51
In one of my recent interviews i appeared, they asked a question like this.
when you run" java filename n1 n2 n3 n4" here n1,n2 are integers. n3,n4 are floats.
you must get the output as result of (n1/n2) ,(n3/n4) .
please frame a programme which satisfies the above question.

SCJP 5
James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

Just go through the wrapper classes and look in to constructors.
You will find answer


MAke sure you use meaningful title .Not like solve this please

SCJP 6
Why to worry about things in which we dont have control, Why to worry about things in which we have control ! !
manoj manny
Greenhorn

Joined: Mar 04, 2009
Posts: 4
public class Test {
<solution deleted>
}

ENJOY
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14276
    
  21

Teja Hyd,

When you post a question on JavaRanch, please carefully choose one forum. You have posted this in the SCJP forum, but this questions looks like it does not has anything to do with the SCJP exam.

I will move it to a more appropriate forum for you. Next time, take a moment to think about what forum to post your question in.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

Slightly diff version of the same program:

public class Test {
<solution deleted>
}


Java tiger was not introduced till 1.5 so i would prefer he does not get compiler errors if using an older version.


As an explaination:

java A W X Y Z


'A' is name of class file containing the main program. 'W', 'X', 'Y', 'Z' are the parameters you send to the program. I dont knw the upper limit as to how many parameters can be sent, but they are recieved in a String array which we usually name "args"


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

teja hyd wrote:


Please check your private messages for an importand administrative matter.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

manoj manny wrote:


Please check your private messages for an important administrative matter.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11422
    
  16

Please don't post solutions like this. We try very hard here to teach folks how to program, and handing them an answer doesn't accomplish that. Make suggestions, point them towards a class they can use, or even post a code snippet - but not the full blown solutions.

this is particularly important if someone is posting a homework assignment. If they submit what you posted, they can get in trouble for plagarism. I know the O.P. said this was an interview question, but can you really be sure?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Hector Tenedero
Ranch Hand

Joined: Oct 13, 2008
Posts: 31
There's a tutorial somewhere in this site that might help you. After reading, it got stuck in my head.
teja dharma
Ranch Hand

Joined: Feb 07, 2009
Posts: 51
James Tharakan wrote:Just go through the wrapper classes and look in to constructors.
You will find answer


MAke sure you use meaningful title .Not like solve this please

dear james in the question n1 n2 n3 n4 i mean they are the parametrs which we give at run time.
execute this programme you can get my question my clear now

public class Sampleinput {

solution deleted. please don't provide direct answers.

}
execute like this
java Sampleinput 4 2 4.0 2.0
you will get the output as
2
2.0
U are preparing for SCJP i think you must be familiar with this topics which worths you
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

"teja hyd",
Did you check your private messages as I had suggested in my previous post?
If not, please do so.

Kedar Nath
Ranch Hand

Joined: Sep 02, 2008
Posts: 53
@ teja hyd

What james said is right. There is a constructor in both Float and Integer class. Which creates an objects of their respective class with string paramaters. And the command lines inputs are taken as strings.

And the solution that you gave is already deleted. And i cant comment on that .

James Tharakan
Ranch Hand

Joined: Aug 29, 2008
Posts: 580

If you are talking about the input other than command line argument, then you can use the scanner class of util package. With it methods like hasnext(), nextInt() and nextFlaot() will give you the solution.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: solve this please