Programming Assignment 3 Instructions Exercise 4.12: Write an application that calculates the product of the odd integers from 1 to 15. Exercise 4.16 JHTP (Bar Chart Printing Program): One...

1 answer below »


Programming Assignment 3 Instructions



Exercise 4.12:
Write an application that calculates the product of the odd integers from 1 to 15.




Exercise 4.16 JHTP (Bar Chart Printing Program):
One interesting application of computers is to display graphs and bar charts. Write an application that reads 5 numbers between 1 and 30. For each number that reads, your program will display the same number of adjacent asterisks. For example, if your program reads the number 7, it will display *******. Display the bars of asterisk after you read all 5 numbers.


Programs must include comments.


Answered Same DayJun 30, 2021

Answer To: Programming Assignment 3 Instructions Exercise 4.12: Write an application that calculates the...

Yogesh answered on Jul 01 2021
155 Votes
Sol_1.java
Sol_1.java
public class Main {
    public static void main(String[] args) {
        /
/ Initialise variables for starting and ending numbers and result(products of numbers)
        int num1 = 1;
        int num2 = 15;
        int result = 1;

        // for loop iterates over the range from starting to ending number
        for(int i = num1; i<= num2; i++){
            // if loop checks for Odd integers and if the number is Odd then calculate product
            if(i % 2 != 0){
                //System.out.println(i);
                result = result * i;
            }
        }
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here