Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi I have a Code which i want to run and test it, but i got this error and i cou

ID: 3589785 • Letter: H

Question

Hi

I have a Code which i want to run and test it, but i got this error and i could not dubug the lines to know if i test all the paths like in the pic which i atteched

Error: Main method not found in class Sss, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

Could you please help me to run it

the code is :

public class Sss {

int sillyProduct(int arr[], int num) {

int product = 700;

int counter = 2;

while (counter < num && arr[counter] > 0) {

if (arr[counter] > 1 && arr[counter] % 2 != 0) {

product = product * arr[counter];

}

counter = counter + 2;

}

return product;

}

}

Do not forget that to show the output to know the result of prodect and num after my assume

For example:

num =3

what is the output from my assume this numbers!!

output

counter = .....

product =....

arr[] = ....

arr[counter] = ....

3 4 nodes are named after line numbers false true false 7 true J-1 FG-1

Explanation / Answer

if you want to debug you should have executale,, to produce executable and run your prgram , we need main method from where we can call the function sillyProduct

for that we nedd to include main method and define the silly product with static keyword before int ,, now execute and debug your program.

I have given modified code and sample output

//program in java

public class Sss {
static int sillyProduct(int arr[], int num)
{

int product = 700;
int counter = 2;
num = 3;
arr[counter] = 2;
while (counter < num && arr[counter] > 0)
{
if (arr[counter] > 1 && arr[counter] % 2 != 0)
{
product = product * arr[counter];
}
counter = counter + 2;
}
return product;
}
public static void main(String args[]) {
int [] arr = new int[10];
//place some numbers in array
for(int i = 0; i <10; i++)
arr[i] = i + 1;
//now call the function sillyProduct
System.out.printf("product returned from function sillyProduct = %d ",sillyProduct(arr,2));
}
}

----------------------------------------------

//output

product returned from function sillyProduct = 700