You are on page 1of 5

BARANI Institute of Management Sciences

Assignment # 1
Modern Programming Language

Deadline: November 10th, 2022

(Thursday)

IMPORTANT NOTE (READ IT FIRST)


 ASSIGNMENT MUST BE PROPERLY FORMATTED IN MS-WORD ALONG WITH TITLE PAGE IN FILE
 COLOR OF THE TEXT MUST BE AS IN THE NETBEANS IN THE SUBMITTED PROGRAM (SEE EXAMPLE)
 AVOID PLAGIARISM FROM INTERNET AND FROM OTHER STUDENTS AT ALL COSTS
 COPY OF TEXT FROM OTHERS WILL RESULT IN FAILED ASSIGNMENT & FAILED FUTURE ASSIGNMENTS
 LATE SUBMISSIONS WILL NOT BE ACCEPTED OR ENTERTAINED AT ANY COST OR REASON
 ALL MEMBERS WILL ATTEMP AND SUBMIT THEIR OWN ASSIGNMENT BY THEMSELVES
 PROGRAM MUST DISPLAY THE SAME OUTPUT DISPLAY AS THE SAMPLE OUTPUT
 ASSIGNMENT WILL BE EVALUATED VIA VIVA OR MENTIONING CHANGES IN PROGRAM ON RUN TIME.

 COPY ASSIGNMENTS WILL CONSIDER ZERO BOTH PF THEM

Example how code should look like:


[Hint: Find Plugin to copy RTF text]

public class Welcome


{
// Main Method
public static void main(String[] args)
{
// Display Output
System.out.println("Welcome to Java Language!");
}
}

Object Oriented Programming Page|1


Assignment Tasks:
Group 01: Program 1
Group 02: Program 2(a) and 2(b)
Group 03: Program 3
Group 04: Program 4
Group 05: Program 5
Group 06: Program 1
Group 07: Program 2(a) and 2(b)
Group 08: Program 3
Group 09: Program 4
Group 10: Program 5

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

Enter Number: 9 or 101


Invalid Number! Number must be between 10 and 100

Object Oriented Programming Page|2


Program 2(a):
Write a Java program to convert milliseconds to hour, minute. Seconds, and
milliseconds.

Sample Output:
Enter milliseconds: 86399867

Total Time = 23:59:59.867

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 Created with opening balance of 3000!

Enter Withdrawal Amount: 1000

Account Debited!
New Balance: 2000

Enter Deposit Amount: 3000

Object Oriented Programming Page|3


Account Credited!
New Balance: 5000

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

Enter x for 2^x: 4


2^4 is 16

Enter x for x^2: 3


3^2 is 9

Enter x for x^y: 2


Enter y for x^y: 3
2^3 is 8

Enter x for x!: 5


5! is 120

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

Object Oriented Programming Page|4


FOR SQUARE:
Enter Length: 4
Area: 16

Object Oriented Programming Page|5

You might also like