Assignment 5
Assignment 5
1.WJP to print even numbers between 1 to 10 using for loop and if else
3.WJP to find sum of even numbers from 1 to 10 and 10 to 1 with iteration part
5.
Algorithm:
Start
Create an instance of the Scanner class.
Declare a number
Ask the user to initialize the number.
Use a for loop to print the multiplication table of that number.
Display the result.
Stop.
WJP for above algorithm.
10.WJP Write a program to print the Fibonacci series using a while loop.
Example: Input 5 → Output: 0, 1, 1, 2, 3
11.WJP Write a program to calculate the sum of digits in a number using a while
loop.
Example: Input 1234 → Output: 10
12.WJP Use a while loop to print the multiplication table of a given number.
Example: Input 5 → Output: 5, 10, 15, ...
14.WJP to find the sum of all prime numbers between two given numbers using a
while loop.
*
**
***
****
*****
16.Inverted Right-Angled
*****
****
***
**
*
17.Pyramid Pattern
*
***
*****
*******
18.Hollow Square
*****
* *
* *
* *
*****
19.Floyd's Triangle.
1
2 3
4 5 6
7 8 9 10
20.Pascal's Triangle
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
21.Butterfly Pattern
* *
** **
*** ***
********
*** ***
** **
* *
*
* *
* *
* *
* *
* *
*
23.Hourglass Pattern
*********
*******
*****
***
*
***
*****
*******
*********
24.Zig-Zag Pattern
* *
* * * *
* * *
25. Write a java program to perform the addition of two matrices using nested
for loops.
26.Write a java program to print all prime numbers between 1 and N using a for
loop.
Example: Input N = 20 → Output: 2, 3, 5, 7, 11, 13, 17, 19
30.
Basic ATM Simulator
Description: Simulate basic ATM operations like checking balance, depositing
money, and withdrawing money.
Features:
Use a loop to display a menu with options (e.g., 1. Check Balance, 2. Deposit,
3. Withdraw, 4. Exit).
Perform actions based on user input.
Validate withdrawal amounts to ensure sufficient balance.
How It Works
Initial Balance: