0% found this document useful (0 votes)
1 views

Java_Exercises (1)

The document outlines several programming tasks including printing the natural logarithm of e, determining if a number is even or odd, reversing a positive integer, calculating bank interest based on user input, and printing specific patterns using loops. Each task is described with specific requirements and examples. The document serves as a guideline for coding exercises in a programming context.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Java_Exercises (1)

The document outlines several programming tasks including printing the natural logarithm of e, determining if a number is even or odd, reversing a positive integer, calculating bank interest based on user input, and printing specific patterns using loops. Each task is described with specific requirements and examples. The document serves as a guideline for coding exercises in a programming context.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1. Write a program to print the result of 𝑙𝑛(𝑒).

2. Write a function that takes a parameter n, if n is even, returns true, if it is odd, returns false.
3. Write a function that takes a positive integer and returns the reverse of the number passed.
For example, pass in the function a number 12345, returns 54321. (Do not print out the
screen in the function)
4. Write a program to calculate bank interest that allows the user to enter the deposit amount
and the number of months wants to deposit. Calculate the amount the customer is
expected to receive based on the following formula:
The amount received = Deposit amount + Deposit amount * Interest rate
Number of months Interest rate
Number of months <= 3 months 1%
Number of months <= 6 months 1.5%
Number of months < 12 months 3%
Number of months = 12 months 5%
The program only allows users to enter a positive integer that <= 12. In case of incorrect
input, notify the user and allow re-entry.
5. Write a function that takes the parameter n, using loops to print the following figures to
the screen according to the value of n passed:
n=3
*
***
*
n= 5
*
***
*****
***
*
n= 7
*
***
*****
*******
*****
***
*

You might also like