Answered step by step
Verified Expert Solution
Question
1 Approved Answer
//MathOperation.java import java.util.Scanner; public class MathOperation { //A int intNum1; int intNum2; float fNum1; float fNum2; int op; //B public MathOperation() { intNum1 = 0;
//MathOperation.java import java.util.Scanner; public class MathOperation { //A int intNum1; int intNum2; float fNum1; float fNum2; int op; //B public MathOperation() { intNum1 = 0; intNum2 = 0; fNum1 = 0; fNum2 = 0; op = 0; } //C public MathOperation(int n1, int n2, int n) { intNum1 = n1; intNum2 = n2; fNum1 = 0; fNum2 = 0; op = n; } //D public MathOperation(float d1, float d2, int n) { fNum1 = d1; fNum2 = d2; intNum1 = 0; intNum2 = 0; op = n; } //E public String toString() { String str = "CALCULATOR OF LIEM LE"; String str2 = "", str3 = ""; int iRet= 0; float fRet = 0.0f; switch (op) { case 1: // add 2 int str2 = "ADD TWWO INTEGERS"; iRet = intNum1 + intNum2; str3 = intNum1 + " + " + intNum2 + " = " + iRet; break; case 2: // minus 2 int str2 = "MINUS TWWO INTEGERS"; iRet = intNum1 - intNum2; str3 = intNum1 + " - " + intNum2 + " = " + iRet; break; case 3: // multiply 2 int str2 = "MULTIPLY TWWO INTEGERS"; iRet = intNum1 * intNum2; str3 = intNum1 + " * " + intNum2 + " = " + iRet; break; case 4: // divide 2 int str2 = "DIVIDE TWWO INTEGERS"; iRet = intNum1 /intNum2; str3 = intNum1 + " / " + intNum2 + " = " + iRet; break; case 5: // add 2 float str2 = "ADD TWWO DECIMAL NUMBERS"; fRet = fNum1 + fNum2; str3 = fNum1 + " + " + fNum2 + " = " + fRet; break; case 6: // minus 2 floaf str2 = "MINUS TWWO DECIMAL NUMBERS"; fRet = fNum1 - fNum2; str3 = fNum1 + " - " + fNum2 + " = " + fRet; break; case 7: // multiply float str2 = "MULTIPLY TWWO DECIMAL NUMBERS"; fRet = fNum1 * fNum2; str3 = fNum1 + " * " + fNum2 + " = " + fRet; break; case 8: // divide float str2 = "DIVIDE TWWO DECIMAL NUMBERS"; fRet = fNum1 / fNum2; str3 = fNum1 + " / " + fNum2 + " = " + fRet; break; } return str + " " + str2 + " " + str3 + " "; } }
Please help me with this problem, its very simple but i dont know why eclipse wont work. Thanks
Create a new project, add source file to the project, compile and run the program without errors and qualified to the requirement Declare variables of int, double, String provide UML of data types -Create data types with data members, constructors, mutator methods Apply Inheritance relationship Apply polymorphism in the project provide the pseudo-code of program create and manage the menu to loop back to re-display after each task: using do.. while -Use switch statement to determine and define the action for each task Format the output in columns and double numbers wiwth 2 decimal digits Display message box To do this lab, students have to know Review to create the pseudo-code or a flowchart of a lab Review the syntax to create a data type class with data members, constructors, mutator accessor methods, method toString Review how to define a child class including data member, constructor, toString and other methods inheriting from parent class: Review how to declare an object in main), how to access the methods of data type classes from main() -Review how to apply polymorphism Review control structure: if..else, switch, do..while loop How to set the decimal digits (2) of a double number How to display the message boxStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started