Write a java source code that calculates the product of only odd numbers from 1 to N,
Question:
Write a java source 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.
- 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.
- 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.
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.
Problem 2:
Write an application that prints the following diamond shape. You may use output statements that print a single asterisk (*), a single space, or a single new-line character. The output of the program is listed in the textbook. Please use the While loop only to print the shape.
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe