Quick Java Programming question....

Skiguy411

Platinum Member
Dec 4, 2002
2,093
0
0
I am suppose to write a public method named multiply which accepts two doubles multiplies them, and returns a double.

I'm just starting to learn java and so I'm not** exactly sure how to write that.
 

imported_nautique

Senior member
Jul 14, 2004
346
0
0
Come on man that is standard stuff and the wrong place to be asking. You can easily accomplish that task. In literally 2 min.
 

BigJ

Lifer
Nov 18, 2001
21,330
1
81
Private or Public?: public
Return type: double
Method Name: multi
Inputs: (double a, double b) {

That's a huge hint.

 

KLin

Lifer
Feb 29, 2000
30,091
473
126
Originally posted by: Skiguy411
I am suppose to write a public method named multiply which accepts two doubles multiplies them, and returns a double.

I'm just starting to learn java and so I'm exactly sure how to write that.

You're exactly sure? Not just sure, but exactly sure?
 

Skiguy411

Platinum Member
Dec 4, 2002
2,093
0
0
Originally posted by: Tu13erhead
Read your book? Use class notes? Ask a professor? Google?

I figured with ATOTs wisdom, it would be the fastest and most painless way to find out.
 

purbeast0

No Lifer
Sep 13, 2001
53,448
6,295
126
wow that is fvcking pathetic. i really really hope for your sake that your major has nothing to do with computers at all, as in, you will never ever touch a computer while on your job after you have a degree.
 

Skiguy411

Platinum Member
Dec 4, 2002
2,093
0
0
Originally posted by: purbeast0
wow that is fvcking pathetic. i really really hope for your sake that your major has nothing to do with computers at all, as in, you will never ever touch a computer while on your job after you have a degree.

Errmm....we all have to start out somewhere don't we?
 

BigJ

Lifer
Nov 18, 2001
21,330
1
81
Originally posted by: Skiguy411
Originally posted by: purbeast0
wow that is fvcking pathetic. i really really hope for your sake that your major has nothing to do with computers at all, as in, you will never ever touch a computer while on your job after you have a degree.

Errmm....we all have to start out somewhere don't we?

Most people would start out by reading the book, or paying attention to the lectures in class, where the professor absolutely went over this.

Do yourself a favor and switch majors.
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
This is the simplest possible example of a function returning a value, this was covered in class and your book goes into excessive detail.

You need to learn basic concepts like this. If you just learn to copy and paste other people's code you will fail the midterm and final, and you will be hopelessly unprepared for any future classes.

Programming is not like a history class where you memorize some facts and spew them out. It's more like a math class where you learn tools and how to use them.

Learn the concepts or switch to a business major.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
public static double multiply(double a, double b)
{
double c = a * b;
if (c > 0)
return c;
else
system.exit(0);

return c;
}

This is the best example. Don't listen to these noobs. :p
 

DaveSimmons

Elite Member
Aug 12, 2001
40,730
670
126
Originally posted by: tfinch2
public static double multiply(double a, double b)
{
double c = a * b;
if (c > 0)
return c;
else
system.exit(0);

return c;
}

This is the best example. Don't listen to these noobs. :p
Exactly! If you're going to copy-paste answers this one will impress the professor more with its variety of responses and attention to detail.