Question: hello I am stuck on this assignment, can someone point me in the right direction. this is Java The project name of this exercise is

hello I am stuck on this assignment, can someone point me in the right direction. this is Java

The project name of this exercise is Multiply.

The purpose of this assignment is to practice creating a class then using it to solve a problem.

Start this exercise using the technique on the web page titled "How to Start Every Project in this Class". When complete you should have a Program.java file ready for you to fill with code. Replace all of the code present with the code contained in the box below:

package edu.sbcc.cs105;


public class Program {


/**

* This method creates a Multiply object and then uses it to multiply 2 by

* 3. It prints out this result along with the expected result for error

* checking.

*/

public static void main(String[] args) {

Multiply multiply = new Multiply();


int shouldBeSix = multiply.byTwo(3);


System.out.println("If you double 3 you should get 6 and we get "

+ shouldBeSix + ".");


int shouldBeEight = multiply.getProduct(2, 4);

System.out.println("The Product of 2 x 4 is " + shouldBeEight + ".");

}


}


You can simply copy the code from the grey box and paste it into the Program.java file.

Next, rt click on edu.sbcc.cs105, New->Class to create a Multiply class and you should have the file Multiply.java. Replace the code in that file with the code in the grey box below. This one is a little tougher because you have to edit the calculation in getProduct to return the product of the two passed operands - don't forget to replace ' ' with the statement to do the calculation in Java.

package edu.sbcc.cs105;


public class Multiply {


/**

* Multiplies input integer by 2, returns

* input integer multiplied by two.

*/

public int byTwo(int multiplicand) {

return multiplicand * 2;

}


/**

* Calculates and returns product of two integers.

* returns the product of the two passed input integers.

*/

public int getProduct(int operand1, int operand2) {


// TODO: calculate result

int result =

return result;

}

}



Run the code by single clicking on Program.java in the package explorer and selecting Run->Run from the menu.


Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!