Object Oriented Programming Assignment2
Object Oriented Programming Assignment2
Object Oriented Programming Assignment2
PROGRAMMING
Implementation of Different Java Programs
21-April-2024
TABLE OF CONTENT
1: Savings Calculator..................................................................................................................
Summary:..................................................................................................................................
Conclusion:...............................................................................................................................
PAGE 1
1: Savings Calculator.
Task: The task was to create a Java program that calculates the value of a savings
account after a certain number of months, taking into account a fixed monthly
deposit and an annual interest rate
Solution: The program prompts the user to enter the initial amount, annual
interest rate, and the number of months. Then, it calculates the value of the
savings account after the given number of months using compound interest
formula and displays the result.
The program calculates the amount in a savings account after a given number of
months, considering monthly deposits and compound interest. It follows these
steps:
Input: Prompts the user for the initial amount, annual interest rate, and
number of months.
Output: Displays the amount in the savings account after the specified number
of months.
CODE:
RESULT:
PAGE 2
2: LOTTERY NUMBER GENERATOR:
Task: The task was to create a Java program that generates a two-digit lottery number
with distinct digits.
Solution: The program generates the first digit between 1 and 9 and then continuously
generates the second digit until it's different from the first one. Finally, it combines the
digits to form the two-digit lottery number and displays it.
The program generates a two-digit lottery number with distinct digits. It follows these
steps:
Random Number Generation: It generates the first digit between 1 and 9 and
the second digit between 0 and 9, ensuring it's different from the first digit.
Combination: It combines the digits to form the two-digit lottery number.
Output: It displays the generated lottery number.
CODE:
OUTPUT:
PAGE 3
3: MEAN AND STANDARD DEVIATION CALCULATOR:
Task: The task was to create a Java program that calculates the mean and standard
deviation of ten numbers entered by the user.
Solution: The program prompts the user to enter ten numbers, calculates their mean,
and then calculates the standard deviation. Finally, it displays the mean and standard
deviation.
The program calculates the mean and standard deviation of ten numbers provided by
the user. It follows the steps outlined below:
CODE:
OUTPUT:
PAGE 4
4. BUBBLE SORT ALGORITHM
Task: The task was to create a Java program that implements the bubble sort algorithm
to sort ten double numbers entered by the user.
Solution: The program reads in ten double numbers from the user, then sorts them
using the bubble sort algorithm and finally displays the sorted numbers.
The program implements the bubble sort algorithm to sort ten double numbers
provided by the user. It performs the following steps:
CODE:
OUTPUT:
PAGE 5
5. BINARY OPERATIONS CALCULATOR:
Task: The task was to create a Java program that performs binary operations on
integers based on the given operator and operands.
Solution: The program takes three parameters: an operator (+, -, *, /) and two integers.
It then performs the specified operation on the integers and displays the result
The program performs binary operations on two integers based on the provided
operator. It follows these steps:
CODE:
OUTPUT:
PAGE 6
SUMMARY:
Each of the five Java programs fulfills a specific task:
CONCLUSION:
Each of these Java programs addresses specific tasks: generating lottery numbers and
calculating savings growth over time, calculating statistics, sorting data, and
performing arithmetic operations. By explaining the questions and the solutions
provided, users can better understand the purpose and functionality of each program.
Each program addresses a specific problem and provides a clear solution, enhancing
the versatility and usefulness of the collection of programs.
SUBMITTED BY:
Dua Fatima (BB-7577), Alishba Arif (BB-7917), Sineha (BB-7608), Rimsha Saher
(BB-7407), Sakeena Tahir (BB-7904)
PAGE 7