Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem 1: Write a java source code that calculates the product of only odd numbers from 1 to N, where N is the input that

Problem 1:

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

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

Students also viewed these General Management questions