Click here to Skip to main content
15,888,461 members
Home / Discussions / Java
   

Java

 
QuestionMethod Pin
Member 1147410123-Feb-15 16:46
Member 1147410123-Feb-15 16:46 
AnswerRe: Method Pin
SakthivelPalaniyappan23-Feb-15 18:52
SakthivelPalaniyappan23-Feb-15 18:52 
AnswerRe: Method Pin
Afzaal Ahmad Zeeshan23-Feb-15 20:31
professionalAfzaal Ahmad Zeeshan23-Feb-15 20:31 
GeneralRe: Method Pin
Member 1147410126-Feb-15 13:51
Member 1147410126-Feb-15 13:51 
SuggestionRe: Method Pin
Richard MacCutchan24-Feb-15 0:12
mveRichard MacCutchan24-Feb-15 0:12 
Questioncompiling my code Pin
Member 1147410123-Feb-15 15:52
Member 1147410123-Feb-15 15:52 
SuggestionRe: compiling my code Pin
Richard MacCutchan23-Feb-15 21:51
mveRichard MacCutchan23-Feb-15 21:51 
Questionadding multiply and division method Pin
Member 1147410123-Feb-15 14:29
Member 1147410123-Feb-15 14:29 
Please can someone assist in debug the below code. I am trying to add multiply and division method to the code whereby both methods can accepts two parameters and return a value.



class MathOP{
double num1;
double num2;
//create a method mathadd
double mathadd(){
return num1 + num2;
}
// create a method mathsub
double mathsub(){
return num1 -num2;
}
//set value of mathop for test
void setVal(double x, double y) {
num1 = x;
num2 = y;
}
}

/************************

This is a flower box

Name:

Program name:

Date:

Purpose:
**************************/

class TestMathOP {
public static void main (String args[]) {
MathOP mytest1 = new MathOP();
MathOP mytest2 = new MathOP();
MathOP mytest3 = new MathOP();
double Mathadd;
double Mathsub;
double Mathadd1;

//intitialize each text
mytest1.setVal(5.5, 7.5);
mytest2.setVal(5.5, 7.5);
mytest3.setVal(5.5, 7.5);

//get values
Mathadd = mytest1.mathadd();
System.out.println("The sum of two number is " + Mathadd);

//get values of subtraction
Mathsub = mytest2.mathsub();
System.out.println("The subtraction of two number is " + Mathsub);
boolean Y = true;

System.out.println("Do you want to exist (Y/N)?");

if (Y) {

System.out.println("Thanks for using our system");
}else{
System.out.println("run the program again");


}
}

//Modify the code to prompt for the operation
class TestMathOP1 {
void main (String args[]) {
MathOP mytest3 = new MathOP();
double Mathadd1;

Mathadd1 = mytest3.mathadd();
System.out.println("Enter operator + " + Mathadd1);
System.out.println("Do you want another operation (Y/N)?");


}
}
}

modified 23-Feb-15 20:40pm.

AnswerRe: adding multiply and division method Pin
Akash gods23-Feb-15 17:06
professionalAkash gods23-Feb-15 17:06 
GeneralRe: adding multiply and division method Pin
Member 1147410124-Feb-15 3:35
Member 1147410124-Feb-15 3:35 
AnswerRe: adding multiply and division method Pin
Richard MacCutchan23-Feb-15 21:50
mveRichard MacCutchan23-Feb-15 21:50 
GeneralRe: adding multiply and division method Pin
Member 1147410126-Feb-15 14:05
Member 1147410126-Feb-15 14:05 
GeneralRe: adding multiply and division method Pin
Richard MacCutchan26-Feb-15 21:09
mveRichard MacCutchan26-Feb-15 21:09 
AnswerRe: adding multiply and division method Pin
Akash gods27-Feb-15 9:44
professionalAkash gods27-Feb-15 9:44 
SuggestionRe: adding multiply and division method Pin
Richard MacCutchan27-Feb-15 22:23
mveRichard MacCutchan27-Feb-15 22:23 
GeneralRe: adding multiply and division method Pin
Akash gods28-Feb-15 6:48
professionalAkash gods28-Feb-15 6:48 
GeneralRe: adding multiply and division method Pin
Richard MacCutchan28-Feb-15 6:55
mveRichard MacCutchan28-Feb-15 6:55 
QuestionWhat type of check is made in an ArrayList generic? Pin
Afzaal Ahmad Zeeshan22-Feb-15 7:06
professionalAfzaal Ahmad Zeeshan22-Feb-15 7:06 
AnswerRe: What type of check is made in an ArrayList generic? Pin
Richard MacCutchan22-Feb-15 7:38
mveRichard MacCutchan22-Feb-15 7:38 
GeneralRe: What type of check is made in an ArrayList generic? Pin
Afzaal Ahmad Zeeshan22-Feb-15 8:47
professionalAfzaal Ahmad Zeeshan22-Feb-15 8:47 
AnswerRe: What type of check is made in an ArrayList generic? Pin
jschell23-Feb-15 10:21
jschell23-Feb-15 10:21 
GeneralRe: What type of check is made in an ArrayList generic? Pin
Afzaal Ahmad Zeeshan23-Feb-15 20:26
professionalAfzaal Ahmad Zeeshan23-Feb-15 20:26 
GeneralRe: What type of check is made in an ArrayList generic? Pin
jschell26-Feb-15 9:50
jschell26-Feb-15 9:50 
Questionproject Pin
Member 1146518219-Feb-15 10:35
Member 1146518219-Feb-15 10:35 
AnswerRe: project Pin
Richard Andrew x6419-Feb-15 12:25
professionalRichard Andrew x6419-Feb-15 12:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.