12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
-
- /**
- * Write a description of class CoreFeatures here.
- *
- * @author (your name)
- * @version (a version number or a date)
- */
- public class CoreFeatures {
-
- public double add(double x) {
- double y = Console.getDoubleInput();
- return x + y;
- }
-
- public double subtract(double x) {
- double y = Console.getDoubleInput();
- return x - y;
- }
-
- public double multiply(double x) {
- double y = Console.getDoubleInput();
- return x * y;
- }
-
- public double divide(double x) {
- double y = Console.getDoubleInput();
- if (y == 0){
- this.error();
- return 0;
- }
- return x / y;
- }
-
- public double square(double x) {
- return Math.pow(x,2);
- }
-
- public double sqrt(double x) {
- if (x < 0){
- this.error();
- return 0;
- }
- return Math.pow(x,0.5);
- }
-
- public double exp(double x) {
- double y = Console.getDoubleInput();
- return Math.pow(x,y);
- }
-
- public double invert(double x) {
- if (x == 0){
- this.error();
- return 0;
- }
- return 1 / x;
- }
-
- public double flip(double x) {
- return -1 * x;
- }
-
- public void error(){
- while (true){
- Console.println("Err");
- String command = Console.getStringInput();
- if (command.equalsIgnoreCase("clear")){
- return;
- }
- }
- }
- }
|