bardcode1 0 Newbie Poster

i need this to work in my program Create a Number Operations Super Class Create an Numbers Operations class that contains common attributes and methods of the child classes create a child class of Number Operations super class that specializes the behavior that is appropriate for the type of operation. Modify the main method so that it only declares the necessary variables and contains the main program control loop. Inside the loop, create objects for each of the defined subclass types

import javax.swing.JOptionPane;


public class Main_Class {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		    String globalInput1;
	        String globalInput2;

			int number1, number2;
			int userResponse1 = 0;
			String strResults;

			//Display Application Introduction
			ProgramDisplay myProgDisplay = new ProgramDisplay();
			myProgDisplay.proDis();
			
			//do-while loop
			do {
				
				
				
				//Process string output and store in integer variables.
				UserInput usrIn = new UserInput();
				number1 = usrIn.getNum(1);
				number2 = usrIn.getNum(2);
		
				NumberOperations myNumOp = new 	NumberOperations(number1, number2);
				

				//Make calculations with the numbers input.
				int sum = myNumOp.calcSum();
			    int diff = myNumOp.calcDiff();
				int product = myNumOp.calcProduct();
				double average = myNumOp.calcAverage();			
				int absoluteValue = myNumOp.calcAbsValue();
				int maxValue = myNumOp.calcMaxNum();
			    int minValue = myNumOp.calcMinNum();
			    
			    InputValidation myIV = new InputValidation(number1, number2);
			    String strResults1 = myIV.calc1HundredOrNeg();

				strResults = "Sum: \n " + "     " + number1 + " + " + number2 + " = " + sum + "\n" + 
			    		"Difference: \n" + "     " + number1 + " - " + number2 + " = " + diff + "\n" + 
			    		"Product: \n" + "     " + number1 + " x " + number2 + " = " + product + "\n" +
			    		"The Average is: " + average + "\n" +
						"Absolute Value of Difference:" + "\n" +
			    		"     abs(" + number1 + " - " + number2 + ") = " + absoluteValue + "\n" +
			    		"Max Value: " + maxValue + "\n" +
			    		"Min Value: " + minValue + "\n" +
			    		strResults1 +
						"Would like to play another round?";


				// Display results and ask user for another round of play.
				ProgramDisplay myProgDisplay1 = new ProgramDisplay();
				 userResponse1 = myProgDisplay1.displayResults(strResults);

			}while(userResponse1 == 0);

			//Print exit message.
			JOptionPane.showMessageDialog(null, "Thank you for playing.", "Good Bye...", JOptionPane.INFORMATION_MESSAGE);

			System.exit(0);
		}

	
	}


public class NumberOperations
{
private int number1;
private int number2;

public NumberOperations(int n1, int n2)
{
number1 = n1;
number2 = n2;
}

public int getNum1()
{
return number1;
}

public int getNum2()
{
return number2;
}




public class SumNumbers extends NumberOperations
{

public SumNumbers(int n1, int n2)
{
super(n1, n2);
}

public int calcSum()
{
int sum;
sum = getNum1() + getNum2();
return sum;
}


//calculate difference
public int calcDiff() 
{
	int diff;
	diff = getNum1() - getNum2();
	return diff;
	
}

//calculate product
public int calcProduct() {
	
	return getNum1() * getNum2();
}
//calculate average
public double calcAverage() {
	return (getNum1() + getNum2()) / 2;
}

//calculate absolute value
public int calcAbsValue() {
	int absoluteValue, difference;
	difference = getNum1() - getNum2();
	absoluteValue = Math.abs(difference);
	return absoluteValue;
}

public int calcMaxNum() {
	return Math.max(getNum1(), getNum2());
}

public int calcMinNum() {
	return Math.min(getNum1(), getNum2());
}



}//end of NumberOperations Class



}

import javax.swing.JOptionPane;


public class ProgramDisplay {

	
	public void proDis() {
		

				//display message
				JOptionPane.showMessageDialog(null,
					"Title: NumberGames\n" +
					"By: From jake foster\n" +
					"myprogram \n" +
					"This program lets you input two intergers, it will calculate and display their sum, difference, product and average.\n" +
					"Introduction", null, JOptionPane.PLAIN_MESSAGE);
			}

			public int displayResults(String stringToDisplay) {
				int userResponse1;
				// Display results and ask user for another round of play.
				userResponse1 = JOptionPane.showConfirmDialog(null,
										stringToDisplay,
										"Results", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE);
				return userResponse1;
			}
		

	}


import javax.swing.JOptionPane;
/*
 *
 *comments at the top 
 */
 
public class UserInput {

	
	public UserInput() {
		//default constructor -- nothing to initialize
	}
	
	public int getNum(int n) {
		//Get numbers to be used in calculation from the user.
		String sNum = " ";
		if (n == 1)
			sNum = JOptionPane.showInputDialog("Enter your first integer");
	    else
		    sNum = JOptionPane.showInputDialog("Enter your second integer.");
		
		int num = Integer.parseInt(sNum);
	    return num; 
	   
	}
}
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.