Hey guys so I'm studying computer science and am currently taking a java course. I could really use some help with my project if there are any java experts out there. I'll show you my instructions and paste the code I have so far with what I'm struggling with.
- Write a program that prompts the user for two numbers (double) and a power (another double) and then prints:
- The remainder after the first number is divided by the second number named public double remainder().
- The sum of the square of the two numbers (for example, 32 + 42) named public double sumOfSquares().
- The difference of the square of two numbers (must returns a positive number) named public double differenceOfSquares().
- The sum of the power of the two numbers (and power could be any number, for example, 3x + 4x , where x could be 5 or 6 or 7 or any other number) named public double sumOfPowers().
- The difference of the power of the two numbers (must returns a positive number) named public double differenceOfPowers().
- The square root of the first number plus the square root of the second number named public double sumOfSquareRoots().
2. Implement a class called Calc that represents two double values and a power. The Calc class should have an appropriate constructor that initializes a pair of values (the first two double values) and a power, and methods to return each result required in #1 above.
So you should implement a class called Calc.java that has:
1. Three instance variables (two to hold the two numbers and one to hold the power) - make sure they are private and have accessors and mutators.
2. A default constructor. In the default constructor, set the first and second double values to zero and the power to one.
3. A parameterized constructor that creates and assigns the variables.
4. Six methods as described in requirement #1 the method must be named respectfully:
- public double remainder()
- public double sumOfSquares()
- public double differenceOfSquares()
- public double sumOfPowers()
- public double differenceOfPowers()
- public double sumOfSquareRoots()
- Implement a driver program called CalcTest.java to test your Calc class. The driver program should prompt the user for three doubles (two for the numbers and one for the power), construct a Calc object, call the methods of the Calc class to compute the results, and then display them. Use the JOptionPane or Scanner (your choice) class to perform input. Make sure you test both constructors.
- Use the JavaDoc utility to generate a web page document for your Calc class. Include comments for the class, instance variables, and all methods. In grading your project, we will generate the JavaDoc file from your Calc.java file.
Here is the code I have written so far:
I'm having issues with my methods(I know how to make a basic calculator with addition subtraction etc... but I'm so confused with how to add a division method with remainder. I'm confused with all of them actually) and adding in the other constructor(I believe it's the parameterized constructor because I think the one i have is a default, though I have no clue)
Any help with be so appreciated!