0

hiya i stuck on this can anyone help please

Result1 = (Val1*Val2)/Val3;
Result2 = (Val1+Val2)-Val3;

write a sperate method to print the result of the above calculation


and then write a main app class to create an operator object set it up with some test data to calculate the values above

this is my coding so far:

public class Logic1 {
int Val1;
int Val2;
int Val3;
int Result1;
int Result2;
// creating val 1,2,3 integers

public void Calculations(int Val1, int Val2, int Val3){

Result1 = (Val1*Val2)/Val3;
Result2 = (Val1+Val2)-Val3;
// Writen a method that calculates the above equations.
}

public void setVal1(int newVal1Value)
 {
     Val1 = newVal1Value;
 }
 public int getVal1()
 {
     return Val1;
 }
 // Created get and set for val1
 public void setVal2(int newVal2Value)
 {
     Val2 = newVal2Value;
 }
 public int getVal2()
 {
     return Val2;
 }
 // Created get and set for Val2
public void setVal3(int newVal3Value)
 {
     Val3 = newVal3Value;
 }
 public int getVal3()
 {
     return Val3;
 }
// Created Get and Set for Val3





}

Edited by Ezzaral: Added code tags. Please use them to format any code that you post.

3
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by DavidKroukamp
1

Please use the CODE tags, to make the code readable.

Your code looks OK, what's actually wrong with it?
A tip for any future Java coding: Use Java naming conventions: Classes start with a capital letter (MyClassIsThis), and variables and methods start with a lowercase letter (myMethodIsHere, myVariablesName).

0

hiya i stuck on this can anyone help please

Result1 = (Val1*Val2)/Val3;
Result2 = (Val1+Val2)-Val3;

write a sperate method to print the result of the above calculation


and then write a main app class to create an operator object set it up with some test data to calculate the values above

this is my coding so far:

public class Logic1 {
int Val1;
int Val2;
int Val3;
int Result1;
int Result2;
// creating val 1,2,3 integers

public void Calculations(int Val1, int Val2, int Val3){

Result1 = (Val1*Val2)/Val3;
Result2 = (Val1+Val2)-Val3;
// Writen a method that calculates the above equations.
}

public void setVal1(int newVal1Value)
{
Val1 = newVal1Value;
}
public int getVal1()
{
return Val1;
}
// Created get and set for val1
public void setVal2(int newVal2Value)
{
Val2 = newVal2Value;
}
public int getVal2()
{
return Val2;
}
// Created get and set for Val2
public void setVal3(int newVal3Value)
{
Val3 = newVal3Value;
}
public int getVal3()
{
return Val3;
}
// Created Get and Set for Val3

}

maybe now you will need to get the integers? try using the java scanner class:http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html and store each value into an appropriate values.

Edited by DavidKroukamp: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.