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
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.
Step by Step Solution
3.48 Rating (151 Votes )
There are 3 Steps involved in it
Step: 1
Sure lets tackle both problems step by step Here are the solutions for each problem ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started