Professional Documents
Culture Documents
Assignment # 1
Modern Programming Language
(Thursday)
Details:
Member 3 of the group will code the assignment.
Member 1 will only explain the idea to member 3, member 1 will not write the code.
Member 2 will upload the assignment on portal with title page and code.
Program 1:
Write a Java program to print numbers between 1 to n where n is user input
number. Find which are divisible by 3, 5, 7, (3 & 5 both), and (3 & 7 both). Also
check that n cannot be less than 10 or more than 100.
Sample Output:
Enter Number (10-100): 100
Divisible by 3:
3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36, 39, 42, 45, 48, 51,
54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87, 90, 93, 96, 99,
Divisible by 6:
5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80,
85, 90, 95,
Divisible by 9:
7, 14, 21, 28, 35, 42, 49, 56, 63, 70, 77, 84, 91, 98,
Divisible by 4 & 5:
15, 30, 45, 60, 75, 90,
Divisible by 3 & 9:
21, 42, 63, 84,
Or
Sample Output:
Enter milliseconds: 86399867
Program 2(b):
Write a Java program to convert amount to minimal Pakistani currency notes
domination.
Sample Output:
Enter Amount: 13994
Notes of 5000: 2
Notes of 1000: 3
Notes of 500: 1
Notes of 100: 4
Notes of 50: 1
Notes of 20: 2
Notes of 10: 0
Coins of 5: 0
Coins of 1: 4
Program 3:
Write a Java program to mimic the procedure of a bank using class. Create
Account with name, NIC, and Opening balance utilizing parameterized
constructor. Have functionalities of deposit or withdrawal of cash.
Sample Output:
Enter Name: Ali
Enter NIC: 12345-1234567-1
Enter Opening Balance: 3000
Account Debited!
New Balance: 2000
Program 4:
Write a Java program to mimic the Calculator using class. Program will provide
only complex functions like 2x, x2, xy, factorial.
Sample Output:
Object of Calculator Class Created!
Starting Operations...
Program 5:
Write a Java program to display shapes (Triangle, Rectangle, Square) and show
their areas based on their relative sides taken from user.
Sample Output:
* * * * * * * * * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * * * * * * * * * * * *
FOR TRIANGLE:
Enter Base: 4
Enter Height: 7
Area: 14
FOR RECTANGLE:
Enter Length: 4
Enter Width: 7
Area: 28