Professional Documents
Culture Documents
import java.util.Scanner;
class cons1{//super
this.firstnum = firstnum;
this.secondnum = secondnum;
this.sum=sum;
this.difference=difference;
this.product=product;
this.quotient=quotient;
this.modulo=modulo;
}
}
if(ope == 1) {
sum = (firstnum + secondnum);
System.out.println("\nThe sum of " + firstnum + " + " +
secondnum + " is: " + sum);
} else if (ope == 2) {
difference = (firstnum - secondnum);
System.out.println("The difference of " + firstnum + " - "
+ secondnum + " is: " + difference);
} else if(ope == 3) {
product = (firstnum * secondnum);
System.out.println("The product of " + firstnum + " * " +
secondnum + " is: " + product);
} else if (ope == 4) {
quotient = (firstnum / secondnum);
System.out.println("The quotient of " + firstnum + " / " +
secondnum + " is: " + quotient);
} else if (ope == 5) {
modulo = (firstnum % secondnum);
System.out.println("The modulo of " + firstnum + " % " +
secondnum + " is: " + modulo);
}
}
}
class cons3 extends cons1{//child 2
}
class hybrid extends cons2{//grandchild of child1
char key;
int nYN = 0;
String name = null;
do {
System.out.print("Input 1st number: ");
int firstnum = inp.nextInt();
if(key != 'n' && key != 'N' && key != 'y' && key != 'Y') {
System.out.print("Invalid input. Try again\n");
}
}while (key != 'n' && key != 'N' && key != 'y' && key != 'Y');
} else if (operator == 0) {
ob2.Calcu(firstnum, secondnum, operator);
}
do {
System.out.print("\nContinue? Y or N\n");
key = inp.next().charAt(0);
if(key != 'n' && key != 'N' && key != 'y' && key != 'Y' )
{
System.out.print("Invalid input. Try again\n");
}
}while (key != 'y' && key != 'Y' && key != 'n' && key != 'N' );