I am getting an error saying NumberOperations can't be instantiated. Here is the code.

[LIST=1]
[*]public static void main(String[] args) {
[*]		// TODO Auto-generated method stub
[*]		// declare variables
[*]		int num1, num2, sum, diff, product, average, absolute, max, min, adjusted1, adjusted2, adjustedSum;
[*]		// Display Program Title and Directions
[*]		ProgramDisplay.displayGreeting();
[*]							
[*]		int option = 0;
[*]		do {
[*]			
[*]			// Collect User Input and Create NumberOperattions Object
[*]			num1 = UserInput.getNum("Enter first integer number: ");
[*]			num2 = UserInput.getNum("Enter second integer number: ");
[*]			NumberOperations numOper = new NumberOperations(num1, num2);
[*]			// Calculate Sum 
[*]			sum = numOper.calcSum(); 
[*]			ProgramDisplay.displayResult("The sum of " + num1+ " and " + num2 + " is: ", sum);
[*]			// Calculate Difference 
[*]			diff = numOper.calcDifference(); 
[*]			ProgramDisplay.displayResult("The difference of " + num1+ " and " + num2 + " is: ", diff);
[*]			// Calculate Product 
[*]			product = numOper.calcProduct(); 
[*]			ProgramDisplay.displayResult("The product of " + num1+ " and " + num2 + " is: ", product);
[*]			// Calculate Average
[*]			average = numOper.calcAverage();
[*]			ProgramDisplay.displayResult("The average of " + num1+ " and " + num2 + " is: ", average);
[*]			NumberOperations NumberOper;
[*]			// Calculate Absolute Value of Difference -- note that calcAbsolute is a static (class) method and is invoked using the class name
[*]			absolute = NumberOper.calcAbsolute(diff);
[*]			ProgramDisplay.displayResult("The absolute of " + diff + " is: ", absolute);
[*]						
[*]			// if both numbers are greater than 100, then subtract 100 from each. 
[*]			if (InputValidation.bothMoreThan100(num1, num2)) {
[*]				adjusted1 = num1 - 100;
[*]				adjusted2 = num2 - 100;
[*]				ProgramDisplay.displayResult("The adjusted value of " +  num1+ " is: ", adjusted1);
[*]				ProgramDisplay.displayResult("The adjusted value of " +  num2+ " is: ", adjusted2);
[*]				}
[*]			// if both numbers are negative, then add 200 to their sum.		
[*]			if (InputValidation.bothLessThanZero(num1, num2)) {
[*]				adjustedSum = sum + 200;
[*]				ProgramDisplay.displayResult("The adjusted sum is: ", adjustedSum);
[*]			}		
[*]		} while (ProgramDisplay.terminateApplication());
[*]	}	
[*]	}
[/LIST]

I am getting an error saying NumberOperations can't be instantiated. Here is the code.

Hi charlie,
can you post the code of the NumberOperations contructor!
so that we can c what possibly prevent the creation,
one more Q, the error is runtime error, is not it?]

do { // Collect User Input and Create NumberOperattions Object num1 = UserInput.getNum("Enter first integer number: "); num2 = UserInput.getNum("Enter second integer number: "); NumberOperations numOper = new NumberOperations(num1, num2);

in addition you should take care of defining the opject out side a loop, the NumberOperations numOper=new NumberOperations(num1,num2);
may would be better if you create it with an empty contructor , then use set methods to change the variable each time inside thte loop,

unless the goal of your program requires what you've wrote

if that was not clear hope you send back
Good Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.