0% found this document useful (0 votes)
20 views3 pages

Assignment 5

The document outlines a series of programming tasks primarily focused on Java, including loops, conditionals, and basic algorithms. Each task requires the implementation of specific functionalities such as printing numbers, calculating sums, and creating patterns. Additionally, it emphasizes the importance of using comments, uploading screenshots, and avoiding plagiarism from AI sources.

Uploaded by

seenu.80506
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)
20 views3 pages

Assignment 5

The document outlines a series of programming tasks primarily focused on Java, including loops, conditionals, and basic algorithms. Each task requires the implementation of specific functionalities such as printing numbers, calculating sums, and creating patterns. Additionally, it emphasizes the importance of using comments, uploading screenshots, and avoiding plagiarism from AI sources.

Uploaded by

seenu.80506
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/ 3

Note:- The Document should be in pdf format while uploading

Use scanner class according to the program need


question number is mandatory while making a doc
the question should be mentioned in a comment line in the program
upload screen shot of executed program with output.
Try to complete all the questions.
Don't copy from chat-gpt.

1.WJP to print even numbers between 1 to 10 using for loop and if else

2.WJP to print the number which are divisible by both 3 and 5

3.WJP to find sum of even numbers from 1 to 10 and 10 to 1 with iteration part

4.WJP display your name 5 times 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.

6.WJP that calculates the factorial of a number using a for loop.

7.WJP to count the number of digits in an integer using a while loop.


Example: Input 12345 → Output: 5

8.WJP to Reverse a given number using a do-while loop.


Example: Input 123 → Output: 321

9.WJP Use a do-while loop to calculate the factorial of a number.


Example: Input 5 → Output: 120

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, ...

13.WJP Use a do-while loop to print numbers from N to 1.


Example: Input 5 → Output: 5, 4, 3, 2, 1

14.WJP to find the sum of all prime numbers between two given numbers using a
while loop.

15.Pattern Matching (Right - Angled Stars)

*
**
***
****
*****
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

* *
** **
*** ***
********
*** ***
** **
* *

22.Hallow Diamond 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

27.Print the Fibonacci series up to N terms using a for loop.


Example: Input N = 5 → Output: 0, 1, 1, 2, 3

28.WJP to calculate Profit & loss

29.WJP to get input for salary and age.


if salary greater than or equal to 20000 or age less than or equal to 25
get input for required loan amount. If not print you are not eligible for loan.
if required loan amount is less than or equal to 50,000 print you are eligible
for loan.
if it is greater than 50,000 print maximum loan amount is 50000.

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:

The user starts with a predefined balance (₹1000.0 in this case).


Menu Options:

The menu offers four options:


Check Balance: Displays the current balance.
Deposit Money: Adds a valid amount to the balance.
Withdraw Money: Deducts a valid amount if sufficient balance is available.
Exit: Exits the ATM simulation.
Validation:

Deposits must be positive numbers.


Withdrawals must be positive and not exceed the available balance.
Exit Loop:

The program exits when the user selects option 4.

You might also like