Question: Write a java code that calculates the product of only odd numbers from 1 to N, where N is the input that has been taken
Write a java code that calculates the product of only odd numbers from 1 to N, where N is the input that has been taken from the User(using System.in). The value of N will be any positive number (between 10 and 100)
- You are required to take the value of N from user input. [5 points]
- Need to write a loop instruction to calculate the product. This calculation is required to be done inside a method (aka function) of a class. [15 points]
- Need to print the value of the product on the screen (output). You are required to call a function to get the product value and print the value from the main function. [10 points]
You need to choose the right variable type to store the answer of the product.
Sample Input and Output:
N=10, Output will be 945.
N=20, Output will be 654,729,075.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
