Hi,
Sorry for coming back again and adv thanks for guidance
My tutor gave me a assignment, couple of days before he taught me the work flow of java in eclipse, i am getting through it and i was asked to use constructors for the arithmetic operations as methods in Business location package and choice making, assigning the method as per choice code should be in presentation location package,
Now when i run these packages in cmd compiler says the business package is not available but in eclipse it says "field is not available", i don't even know how right my code could be,
Please tell what was the mistakes i did and i am i following the right way?,
package Business;
public class FirstJavaec{
int a,c,y;
int b, x, res;
public FirstJavaec(){
System.out.println("Inside default constructor");
a=10;
}
public int multi(int x, int b, int res){
res = x*b;
return res;
}
public int addition(int x, int b, int res){
res = x+b;
return res;
}
public int subtract(int x, int b, int res){
res = x-b;
return res;
}
public int div(int x, int b, int res){
res = x/b;
return res;
}
public double module(double x, double b, double res){
res = x/b;
return res;
}
}
package Presentation;
import java.util.*;
import Business.*;
public class OperationsPresent {
public static void main(String[] args) {
String choice;
int x, b, res;
FirstJavaec obj = new FirstJavaec();
obj.multi(x,b,res);
int multi = obj.multi(x, b, res);
Scanner Scanner = new Scanner(System.in);
System.out.println("Enter 1 for Multiplication");
System.out.println("or 2 for Subtraction");
System.out.println("or 3 for Division");
System.out.println("or 4 for Module");
System.out.println("or 5 for Addition");
System.out.println("or your Choice from 1 - 5 " +choice);
choice = Scanner.nextLine();
System.out.println("Enter the First Value" +x);
x = Scanner.nextInt();
System.out.println("Enter the Second Value" +b);
b = Scanner.nextInt();
if(choice=="1"){
obj.multi(x, b, res);
obj.res = obj.x * obj.b;
}
}
}
Ecplise :Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The field FirstJavaec.res is not visible
The field FirstJavaec.x is not visible
The field FirstJavaec.b is not visible
at Presentation.OperationsPresent.main(OperationsPresent.java:33)