├── Assignment-1 ├── output.txt └── Main.java ├── Assignment-4 ├── output.txt └── Main.java ├── Assignment-10 ├── output.txt └── Main.java ├── Assignment-6 ├── output.txt └── Main.java ├── Assignment-11 ├── output.txt └── Main.java ├── Assignment-9 ├── output.txt └── Main.java ├── Assignment-7 ├── output.txt └── Main.java ├── Assignment-8 ├── output.txt └── Main.java ├── README.md ├── Assignment-2 ├── output.txt └── Main.java ├── Assignment-5 ├── output.txt └── Main.java └── Assignment-3 ├── output.txt └── Main.java /Assignment-1/output.txt: -------------------------------------------------------------------------------- 1 | Enter the Complex number in a+bi format : 2 | Enter real part of First Number: a : 4 3 | Enter img part of First Number: b : 5.3 4 | Enter real part of Second Number: a : 2.7 5 | Enter img part of Second Number: b : -6.4 6 | 7 | First Complex Numbers =(4.0)+(5.3)i 8 | Second Complex Numbers =(2.7)+(-6.4)i 9 | 10 | Addition of Complex Numbers =(6.7)+(-1.0999999)i 11 | Substraction of Complex Numbers =(1.3)+(11.700001)i 12 | Multiplication of Complex Numbers =(44.72)+(-11.29)i 13 | Division of Complex Numbers =(-0.479171)+(0.82715017)i 14 | -------------------------------------------------------------------------------- /Assignment-4/output.txt: -------------------------------------------------------------------------------- 1 | MENU 2 | 1.Triangle 3 | 2.Rectangle 4 | 3.Exit 5 | Choice ::1 6 | 7 | ENTER BASE OF TRIANGLE: 5.2 8 | ENTER HEIGHT OF TRIANGLE: 6.6 9 | AREA OF TRIANGLE IS : 17.16 10 | ======================================================= 11 | 12 | MENU 13 | 1.Triangle 14 | 2.Rectangle 15 | 3.Exit 16 | Choice ::2 17 | 18 | ENTER FIRST DIMENSION : 2.0 19 | ENTER SECOND DIMENSION : 9.7 20 | AREA OF RECTANGLE IS : 19.4 21 | ======================================================= 22 | 23 | MENU 24 | 1.Triangle 25 | 2.Rectangle 26 | 3.Exit 27 | Choice ::5 28 | 29 | INVALID INPUT 30 | ======================================================= 31 | 32 | MENU 33 | 1.Triangle 34 | 2.Rectangle 35 | 3.Exit 36 | Choice ::3 37 | 38 | EXITED SUCCESSFULLY 39 | ======================================================= 40 | -------------------------------------------------------------------------------- /Assignment-10/output.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------- 2 | Constructing Hatchback Car 3 | -------------------------------------- 4 | Types of Tyres- Alloy Wheels 5 | Airbags- YES 6 | Back Wiper- YES 7 | Side Mirror- one 8 | Touch Screen Music Player- NO 9 | Roof Window- YES 10 | Automotive Garbage Cans- YES 11 | Automotice Air Freshner- NO 12 | Button Start- YES 13 | -------------------------------------- 14 | assignment.hatchback1@17a7cec2 15 | 16 | 17 | -------------------------------------- 18 | Constructing sedan car 19 | -------------------------------------- 20 | Types of Tyres- Alloy Wheels 21 | Airbags- YES 22 | Back Wiper- NO 23 | Side Mirror- ONE 24 | Touch Screen Music Player- YES 25 | Roof Window- YES 26 | Automotive Garbage Cans- YES 27 | Automotice Air Freshner- NO 28 | Button Start- YES 29 | -------------------------------------- 30 | assignment.sedan2@6f539caf 31 | 32 | 33 | -------------------------------------- 34 | Constructing SUV Car 35 | -------------------------------------- 36 | Types of Tyres- Alloy Wheels 37 | Airbags- YES 38 | Back Wiper- YES 39 | Side Mirror- Two 40 | Touch Screen Music Player- YES 41 | Roof Window- YES 42 | Automotive Garbage Cans- NO 43 | Automotice Air Freshner- YES 44 | Button Start- YES 45 | -------------------------------------- 46 | assignment.suv@50040f0c 47 | -------------------------------------------------------------------------------- /Assignment-6/output.txt: -------------------------------------------------------------------------------- 1 | Enter the Choice which you want to check type of error 2 | 1] Arithmaticexception 2] ArrayOutOfBound 3 | 3] NumberFormat 4] Exit 4 | 1 5 | Enter Two Numbers :: 6 | 4 7 | 0 8 | Cannot Divide by Zero 9 | Enter Valid Denominator.... 10 | 11 | Enter Two Numbers :: 12 | 5 13 | 2 14 | Division is 2.0 15 | ========================================================== 16 | 17 | Enter the Choice which you want to check type of error 18 | 1] Arithmaticexception 2] ArrayOutOfBound 19 | 3] NumberFormat 4] Exit 20 | 2 21 | 22 | Enter the Index No. of Element which you want to print ::56 23 | Invalid Index try again... 24 | 25 | 26 | Enter the Index No. of Element which you want to print ::2 27 | 5 is present at given index 28 | ========================================================== 29 | 30 | Enter the Choice which you want to check type of error 31 | 1] Arithmaticexception 2] ArrayOutOfBound 32 | 3] NumberFormat 4] Exit 33 | 3 34 | Enter first number:: 5 35 | Enter Second number:: jk 36 | Numbers You have Enter are not Integers 37 | Please try again... 38 | 39 | Enter first number:: 6 40 | Enter Second number:: 2 41 | 42 | Entered Numbers are integers::6 , 2 43 | ========================================================== 44 | 45 | Enter the Choice which you want to check type of error 46 | 1] Arithmaticexception 2] ArrayOutOfBound 47 | 3] NumberFormat 4] Exit 48 | 4 49 | ========================================================== 50 | -------------------------------------------------------------------------------- /Assignment-11/output.txt: -------------------------------------------------------------------------------- 1 | **** SHOPING CART **** 2 | 1.Credit Card 3 | 2.PayPal 4 | 3.BitCoin 5 | 4.Exit 6 | 7 | Enter the Choice ::1 8 | ---------------------------------------------------------- 9 | 10 | Enter amount tobe Tranfer :: 350 11 | ---------------------------------------------------------- 12 | ---------------------------------------------------------- 13 | Card holder Name :: Vaibhav 14 | Card Number :: 785423695628 15 | Card Expire Date :: 12/24 16 | ---------------------------------------------------------- 17 | ---------------------------------------------------------- 18 | Paying through CreditCard payment: Charging $350 19 | ---------------------------------------------------------- 20 | 21 | **** SHOPING CART **** 22 | 1.Credit Card 23 | 2.PayPal 24 | 3.BitCoin 25 | 4.Exit 26 | 27 | Enter the Choice ::2 28 | ---------------------------------------------------------- 29 | 30 | Enter amount tobe Tranfer :: 5000 31 | ---------------------------------------------------------- 32 | 33 | Checking Internet Connection........ 34 | ---------------------------------------------------------- 35 | Paying through PayPal payment: Charging $5000 36 | ---------------------------------------------------------- 37 | 38 | **** SHOPING CART **** 39 | 1.Credit Card 40 | 2.PayPal 41 | 3.BitCoin 42 | 4.Exit 43 | 44 | Enter the Choice ::3 45 | ---------------------------------------------------------- 46 | 47 | Enter amount tobe Tranfer :: 10000 48 | ---------------------------------------------------------- 49 | 50 | Enter Transaction 'Input Address' :: 5342.9324.2671.1354 51 | ---------------------------------------------------------- 52 | Paying through BitCoin payment: Charging $10000 53 | ---------------------------------------------------------- 54 | 55 | **** SHOPING CART **** 56 | 1.Credit Card 57 | 2.PayPal 58 | 3.BitCoin 59 | 4.Exit 60 | 61 | Enter the Choice ::5 62 | ---------------------------------------------------------- 63 | Invalid Payment Mode !!! 64 | ---------------------------------------------------------- 65 | 66 | **** SHOPING CART **** 67 | 1.Credit Card 68 | 2.PayPal 69 | 3.BitCoin 70 | 4.Exit 71 | 72 | Enter the Choice ::4 73 | ---------------------------------------------------------- 74 | 75 | Thank you For Shopping !!!! 76 | ---------------------------------------------------------- 77 | -------------------------------------------------------------------------------- /Assignment-9/output.txt: -------------------------------------------------------------------------------- 1 | 1.Create Account 2 | 2.Display Account 3 | 3.Check Balance 4 | 4.Deposit Amount 5 | 5.Withdraw Amount 6 | 6.Exit 7 | Enter your choice: 1 8 | 9 | 10 | Enter your name: Vaibhav 11 | Enter your age: 17 12 | Minimum age should be 18 to create an account. 13 | Please enter valid age: 19 14 | Enter your account Id: 208574521 15 | Enter your account type: Saving 16 | Enter balance: 2400 17 | Enter minimum balance: 500 18 | ================================================= 19 | 20 | 1.Create Account 21 | 2.Display Account 22 | 3.Check Balance 23 | 4.Deposit Amount 24 | 5.Withdraw Amount 25 | 6.Exit 26 | Enter your choice: 2 27 | 28 | Welcome Vaibhav! Following are your account details: 29 | Age :19 30 | Account Id: 208574521 31 | Account Type: Saving 32 | Balance: 2400.0 33 | Minimum balance: 500.0 34 | ================================================= 35 | 36 | 1.Create Account 37 | 2.Display Account 38 | 3.Check Balance 39 | 4.Deposit Amount 40 | 5.Withdraw Amount 41 | 6.Exit 42 | Enter your choice: 3 43 | 44 | Balance is: 2400.0 45 | ================================================= 46 | 47 | 1.Create Account 48 | 2.Display Account 49 | 3.Check Balance 50 | 4.Deposit Amount 51 | 5.Withdraw Amount 52 | 6.Exit 53 | Enter your choice: 4 54 | 55 | Enter the amount you want to deposit: 3600 56 | Amount deposited successfully. Balance is: 6000.0 57 | ================================================= 58 | 59 | 1.Create Account 60 | 2.Display Account 61 | 3.Check Balance 62 | 4.Deposit Amount 63 | 5.Withdraw Amount 64 | 6.Exit 65 | Enter your choice: 5 66 | 67 | Enter the amount you want to withdraw: 6000 68 | Sorry!!! Not enough balance 69 | ================================================= 70 | 71 | 72 | 1.Create Account 73 | 2.Display Account 74 | 3.Check Balance 75 | 4.Deposit Amount 76 | 5.Withdraw Amount 77 | 6.Exit 78 | Enter your choice: 5 79 | 80 | Enter the amount you want to withdraw: 5000 81 | Withdrawal successful. Balance is: 1000.0 82 | ================================================= 83 | 84 | 1.Create Account 85 | 2.Display Account 86 | 3.Check Balance 87 | 4.Deposit Amount 88 | 5.Withdraw Amount 89 | 6.Exit 90 | Enter your choice: 7 91 | 92 | INVALID INPUT !! 93 | ================================================= 94 | 95 | 1.Create Account 96 | 2.Display Account 97 | 3.Check Balance 98 | 4.Deposit Amount 99 | 5.Withdraw Amount 100 | 6.Exit 101 | Enter your choice: 6 102 | 103 | ================================================= 104 | -------------------------------------------------------------------------------- /Assignment-7/output.txt: -------------------------------------------------------------------------------- 1 | ==== MENU BAR ==== 2 | 3 | 1.String 4 | 2.Integer 5 | 3.integer array 6 | 4.String Array 7 | 5.Check Function 8 | 6.Exit 9 | 1 10 | Enter the String :: Madam 11 | Madam is Pallindrome 12 | ====================================================== 13 | 14 | ==== MENU BAR ==== 15 | 16 | 1.String 17 | 2.Integer 18 | 3.integer array 19 | 4.String Array 20 | 5.Check Function 21 | 6.Exit 22 | 1 23 | Enter the String :: Student 24 | Student is not Pallindrome 25 | ====================================================== 26 | 27 | ==== MENU BAR ==== 28 | 29 | 1.String 30 | 2.Integer 31 | 3.integer array 32 | 4.String Array 33 | 5.Check Function 34 | 6.Exit 35 | 2 36 | Enter the Integer :: 1234321 37 | 1234321 is Pallindrome 38 | 1234321 is Odd Number. 39 | 1234321 is Not Prime Number 40 | ====================================================== 41 | 42 | ==== MENU BAR ==== 43 | 44 | 1.String 45 | 2.Integer 46 | 3.integer array 47 | 4.String Array 48 | 5.Check Function 49 | 6.Exit 50 | 2 51 | Enter the Integer :: 2 52 | 2 is Pallindrome 53 | 2 is Even Number. 54 | 2 is Prime Number 55 | ====================================================== 56 | 57 | ==== MENU BAR ==== 58 | 59 | 1.String 60 | 2.Integer 61 | 3.integer array 62 | 4.String Array 63 | 5.Check Function 64 | 6.Exit 65 | 3 66 | Enter size of array:: 4 67 | Enter Array Elements :: 4 6 2 8 68 | Entered Array is :: '4' '6' '2' '8' 69 | ====================================================== 70 | 71 | ==== MENU BAR ==== 72 | 73 | 1.String 74 | 2.Integer 75 | 3.integer array 76 | 4.String Array 77 | 5.Check Function 78 | 6.Exit 79 | 4 80 | Enter size of array:: 6 81 | Enter Array Elements :: ads xd gxdfh fgxdg gdc hfh 82 | Entered Array is :: 'ads' 'xd' 'gxdfh' 'fgxdg' 'gdc' 'hfh' 83 | ====================================================== 84 | 85 | ==== MENU BAR ==== 86 | 87 | 1.String 88 | 2.Integer 89 | 3.integer array 90 | 4.String Array 91 | 5.Check Function 92 | 6.Exit 93 | 5 94 | Enter the String :: 2446 95 | We can perform Pallindrome , int Array , check Prime , EvenOdd Function. 96 | ====================================================== 97 | 98 | ==== MENU BAR ==== 99 | 100 | 1.String 101 | 2.Integer 102 | 3.integer array 103 | 4.String Array 104 | 5.Check Function 105 | 6.Exit 106 | 5 107 | Enter the String :: parent 108 | We can perform Pallindrome , String Array. 109 | ====================================================== 110 | 111 | ==== MENU BAR ==== 112 | 113 | 1.String 114 | 2.Integer 115 | 3.integer array 116 | 4.String Array 117 | 5.Check Function 118 | 6.Exit 119 | 6 120 | ====================================================== 121 | -------------------------------------------------------------------------------- /Assignment-8/output.txt: -------------------------------------------------------------------------------- 1 | 1. Add Records 2 | 2. Display Records 3 | 3. Clear All Records 4 | 4. Search Records 5 | 5. Delete Records 6 | 6. Update Records 7 | 7. Exit 8 | 9 | Enter your choice : 3 10 | 11 | 12 | All Records cleared successfully ! 13 | 14 | ==================================================== 15 | 16 | 1. Add Records 17 | 2. Display Records 18 | 3. Clear All Records 19 | 4. Search Records 20 | 5. Delete Records 21 | 6. Update Records 22 | 7. Exit 23 | 24 | Enter your choice : 1 25 | 26 | 27 | Enter Student Name: vaibhav 28 | Student Id: 12 29 | Roll no: 12 30 | Address: pune 31 | Class: 10 32 | Marks : 489 33 | 34 | Records added successfully ! 35 | 36 | Do you want to add more records ? (y/n) : y 37 | 38 | 39 | Enter Student Name: om 40 | Student Id: 34 41 | Roll no: 34 42 | Address: jalgaon 43 | Class: 9 44 | Marks : 479 45 | 46 | Records added successfully ! 47 | 48 | Do you want to add more records ? (y/n) : y 49 | 50 | 51 | Enter Student Name: yash 52 | Student Id: 67 53 | Roll no: 67 54 | Address: Aurangabad 55 | Class: 9 56 | Marks : 467 57 | 58 | Records added successfully ! 59 | 60 | Do you want to add more records ? (y/n) : y 61 | 62 | 63 | Enter Student Name: Diptesh 64 | Student Id: 76 65 | Roll no: 76 66 | Address: Dhule 67 | Class: 10 68 | Marks : 495 69 | 70 | Records added successfully ! 71 | 72 | Do you want to add more records ? (y/n) : y 73 | 74 | 75 | Enter Student Name: Harsh 76 | Student Id: 39 77 | Roll no: 39 78 | Address: Satara 79 | Class: 11 80 | Marks : 481 81 | 82 | Records added successfully ! 83 | 84 | Do you want to add more records ? (y/n) : n 85 | 86 | ==================================================== 87 | 88 | 1. Add Records 89 | 2. Display Records 90 | 3. Clear All Records 91 | 4. Search Records 92 | 5. Delete Records 93 | 6. Update Records 94 | 7. Exit 95 | 96 | Enter your choice : 2 97 | 98 | vaibhav 12 12 pune 10 489.0 99 | 100 | om 34 34 jalgaon 9 479.0 101 | 102 | yash 67 67 Aurangabad 9 467.0 103 | 104 | Diptesh 76 76 Dhule 10 495.0 105 | 106 | Harsh 39 39 Satara 11 481.0 107 | 108 | 109 | ==================================================== 110 | 111 | 1. Add Records 112 | 2. Display Records 113 | 3. Clear All Records 114 | 4. Search Records 115 | 5. Delete Records 116 | 6. Update Records 117 | 7. Exit 118 | 119 | Enter your choice : 4 120 | 121 | Enter an id of the student you want to search: 34 122 | Record found 123 | om 34 34 jalgaon 9 479.0 124 | 125 | 126 | ==================================================== 127 | 128 | 1. Add Records 129 | 2. Display Records 130 | 3. Clear All Records 131 | 4. Search Records 132 | 5. Delete Records 133 | 6. Update Records 134 | 7. Exit 135 | 136 | Enter your choice : 4 137 | 138 | Enter an id of the student you want to search: 66 139 | Record not found 140 | 141 | ==================================================== 142 | 143 | 1. Add Records 144 | 2. Display Records 145 | 3. Clear All Records 146 | 4. Search Records 147 | 5. Delete Records 148 | 6. Update Records 149 | 7. Exit 150 | 151 | Enter your choice : 5 152 | 153 | Enter the name of the student you want to delete: om 154 | Record found 155 | deleted successfully 156 | Renamed successfully 157 | 158 | ==================================================== 159 | 160 | 1. Add Records 161 | 2. Display Records 162 | 3. Clear All Records 163 | 4. Search Records 164 | 5. Delete Records 165 | 6. Update Records 166 | 7. Exit 167 | 168 | Enter your choice : 6 169 | 170 | Enter the name of the student you want to update: vaibhav 171 | Record found 172 | Enter updated marks: 500 173 | record updated successfully 174 | Renamed successfully 175 | 176 | ==================================================== 177 | 178 | 1. Add Records 179 | 2. Display Records 180 | 3. Clear All Records 181 | 4. Search Records 182 | 5. Delete Records 183 | 6. Update Records 184 | 7. Exit 185 | 186 | Enter your choice : 3 187 | 188 | 189 | All Records cleared successfully ! 190 | 191 | ==================================================== 192 | 193 | 1. Add Records 194 | 2. Display Records 195 | 3. Clear All Records 196 | 4. Search Records 197 | 5. Delete Records 198 | 6. Update Records 199 | 7. Exit 200 | 201 | Enter your choice : 7 202 | 203 | 204 | ==================================================== 205 | -------------------------------------------------------------------------------- /Assignment-1/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //Problem Statement:: 3 | /* 4 | Design a class ‘Complex ‘with data members for real and imaginary part. 5 | Provide default and Parameterized constructors. Write a program to perform 6 | arithmetic operations of two complex numbers. 7 | */ 8 | 9 | package assignment; 10 | import java.util.*; 11 | class Complex_No{ 12 | float real,img;//data member 13 | public Complex_No(){ 14 | //default constructor 15 | real=0; 16 | img=0; 17 | } 18 | public Complex_No(float a ,float b){ 19 | //parameterized constructor 20 | real=a; 21 | img=b; 22 | } 23 | 24 | public void Display(Complex_No C1,Complex_No C2) { 25 | System.out.println("First Complex Numbers =("+C1.real+")+("+C1.img+")i"); 26 | //printing first complex number 27 | System.out.println("Second Complex Numbers =("+C2.real+")+("+C2.img+")i"); 28 | //printing second complex number 29 | } 30 | 31 | public void AddNumbers(Complex_No C1,Complex_No C2) { 32 | //addition of two complex number 33 | float real,img; 34 | real=(C1.real+C2.real); 35 | //real part of complex number 36 | img=(C1.img+C2.img); 37 | //img part of complex number 38 | System.out.println("Addition of Complex Numbers =("+real+")+("+img+")i"); 39 | //printing addition of two complex number 40 | } 41 | 42 | public void SubNumbers(Complex_No C1,Complex_No C2) { 43 | //substraction of two complex number 44 | float real,img; 45 | real=(C1.real-C2.real); 46 | //real part of complex number 47 | img=(C1.img-C2.img); 48 | //img part of complex number 49 | System.out.println("Substraction of Complex Numbers =("+real+")+("+img+")i"); 50 | //priting substraction of two complex number 51 | } 52 | 53 | public void MultiNumbers(Complex_No C1,Complex_No C2) { 54 | //multiplication of two complex number 55 | float real,img; 56 | real=(C1.real*C2.real-C1.img*C2.img); 57 | //real part of complex number 58 | img=(C1.real*C2.img+C1.img*C2.real); 59 | //img part of complex number 60 | System.out.println("Multiplication of Complex Numbers =("+real+")+("+img+")i"); 61 | //printing multiplication of two complex number 62 | } 63 | 64 | public void DivNumbers(Complex_No C1,Complex_No C2) { 65 | //division of two complex number 66 | float real,img; 67 | real=(C1.real*C2.real+C1.img*C2.img)/(C2.real*C2.real+C2.img*C2.img); 68 | //real part of complex number 69 | img=(C1.img*C2.real-C1.real*C2.img)/(C2.real*C2.real+C2.img*C2.img); 70 | //img part of complex number 71 | System.out.println("Division of Complex Numbers =("+real+")+("+img+")i"); 72 | //printing division of two complex number 73 | } 74 | 75 | } 76 | 77 | //======================= CLASS Main =======================// 78 | public class Main { 79 | 80 | public static void main(String[] args) { 81 | float num1,num2; 82 | Complex_No cal=new Complex_No(); 83 | Scanner Sc=new Scanner(System.in); 84 | System.out.println("Enter the Complex number in a+bi format : "); 85 | 86 | //taking input for First Number 87 | System.out.print("Enter real part of First Number: a : "); 88 | num1=Sc.nextFloat(); 89 | System.out.print("Enter img part of First Number: b : "); 90 | num2=Sc.nextFloat(); 91 | Complex_No Com1=new Complex_No(num1,num2); 92 | 93 | //taking input for Second Number 94 | System.out.print("Enter real part of Second Number: a : "); 95 | num1=Sc.nextFloat(); 96 | System.out.print("Enter img part of Second Number: b : "); 97 | num2=Sc.nextFloat(); 98 | Complex_No Com2=new Complex_No(num1,num2); 99 | Sc.close();//clsing scanner close 100 | 101 | System.out.print("\n"); 102 | cal.Display(Com1,Com2); 103 | //calling display function 104 | System.out.print("\n"); 105 | cal.AddNumbers(Com1,Com2); 106 | //calling addition function 107 | cal.SubNumbers(Com1,Com2); 108 | //calling substraction function 109 | cal.MultiNumbers(Com1,Com2); 110 | //calling multiplication function 111 | cal.DivNumbers(Com1, Com2); 112 | //calling division function 113 | 114 | } 115 | 116 | } 117 | 118 | 119 | /* 120 | 121 | OUTPUT 122 | 123 | Enter the Complex number in a+bi format : 124 | Enter real part of First Number: a : 4 125 | Enter img part of First Number: b : 5.3 126 | Enter real part of Second Number: a : 2.7 127 | Enter img part of Second Number: b : -6.4 128 | 129 | First Complex Numbers =(4.0)+(5.3)i 130 | Second Complex Numbers =(2.7)+(-6.4)i 131 | 132 | Addition of Complex Numbers =(6.7)+(-1.0999999)i 133 | Substraction of Complex Numbers =(1.3)+(11.700001)i 134 | Multiplication of Complex Numbers =(44.72)+(-11.29)i 135 | Division of Complex Numbers =(-0.479171)+(0.82715017)i 136 | 137 | */ 138 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Java-OOPL 2 | 3 | ## Object Oriented Programming Assignments of SPPU Second Year IT Syllabus (2019 pattern) 4 | 5 | ### Assignment and Problem Statement 6 | |Assignment|Problem Statement| 7 | |---|---| 8 | |[Assignment1](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-1)|Design a class ‘Complex ‘with data members for real and imaginary part. Provide default and Parameterized constructors. Write a program to perform arithmetic operations of two complex numbers.| 9 | |[Assignment2](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-2)|Identify commonalities and differences between Publication, Book and Magazine classes. Title, Price, Copies are common instance variables and saleCopy is common method. The differences are, Bookclass has author and orderCopies(). Magazine Class has methods orderQty, Current issue, receiveissue().Write a program to find how many copies of the given books are ordered and display total sale of publication.| 10 | |[Assignment3](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-3)|DDesign and develop inheritance for a given case study, identify objects and relationships and implement inheritance wherever applicable. Employee class hasEmp_name, Emp_id, Address,Mail_id, and Mobile_noas members. Inherit the classes: Programmer, Team Lead, Assistant Project Manager and Project Manager from employee class. Add Basic Pay (BP) as the member of all the inherited classes with 97% of BP as DA, 10 % of BP as HRA, 12% of BP as PF, 0.1% of BP for staff club fund. Generate pay slips for the employees with their gross and net salary.| 11 | |[Assignment4](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-4)|Design a base class shape with two double type values and member functions to input the data and compute_area() for calculating area of shape. Derive two classes: triangle and rectangle. Make compute_area() as abstract function and redefine this function in the derived class to suit their requirements. Write a program that accepts dimensions of triangle/rectangle and display calculated area. Implement dynamic binding for given case study.| 12 | |[Assignment5](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-5)|Design and develop a context for given case study and implement an interface for Vehicles Consider the example of vehicles like bicycle, car and bike. All Vehicles have common functionalities such as Gear Change, Speed up and apply breaks. Make an interface and put all these common functionalities. Bicycle, Bike, Car classes should be implemented for all these functionalities in their own class in their own way.| 13 | |[Assignment6](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-6)|Implement a program to handle Arithmetic exception, Array Index Out of Bounds. The user enters two numbers Num1 and Num2. The division of Num1 and Num2 is displayed. If Num1 and Num2 are not integers, the program would throw a Number Format Exception. If Num2 were zero, the program would throw an Arithmetic Exception. Display the exception.| 14 | |[Assignment7](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-7)|Implement a generic program using any collection class to count the number of elements in a collection that have a specific property such as even numbers, odd number, prime number and palindromes.| 15 | |[Assignment8](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-8)|Implement a program for maintaining a database of student records using Files. Student has Student_id,name, Roll_no, Class, marks and address. Display the data for few students. -Create Database 2) Display Database 3) Delete Records 4) Update Record 5) Search Record| 16 | |[Assignment9](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-9)|Using concepts of Object-Oriented programming develop solution for any one application 1) Banking system having following operations :1. Create an account 2. Deposit money 3. Withdraw money 4. Honor daily withdrawal limit 5. Check the balance 6. Display Account information. 2) Inventory management system having following operations : 1. List of all products 2. Display individual product information 3. Purchase 4. Shipping 5. Balance stock6. Loss and Profit calculation.| 17 | |[Assignment10](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-10)|Implement Factory design pattern for the given context. Consider Car building process, which requires many steps from allocating accessories to final makeup. These steps should be written as methods and should be called while creating an instance of a specific car type. Hatchback, Sedan, SUV could be the subclasses of Car class. Car class and its subclasses, CarFactory and Test Factory Pattern should be implemented.| 18 | |[Assignment11](https://github.com/VaibhavBichave/Java-OOPL/tree/main/Assignment-11)|Implement and apply Strategy Design pattern for simple Shopping Cart where three payment strategies are used such as Credit Card, PayPal, Bit Coin. Create an interface for strategy pattern and give concrete implementation for payment.| 19 | -------------------------------------------------------------------------------- /Assignment-4/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //Problem Statement:: 3 | /* 4 | design a base class shape with two double type values and member function to 5 | input the data and compute area() for calculating area of shape. Derive two classes 6 | Triangle and Rectangle make compute area() as abstract function and redefine this function 7 | in the derive class to suit their requirement .Write a program that accepts the dimension 8 | of Triangle /Rectangle and display calculated area. Implement dynamic binding. 9 | */ 10 | 11 | package assignment; 12 | import java.util.*; 13 | abstract class shape { 14 | 15 | private double dimen1,dimen2; //private data members 16 | 17 | double getDimen1() //method to return dimension 1 18 | { 19 | return dimen1; 20 | } 21 | 22 | double getDimen2() //method to return dimension 2 23 | { 24 | return dimen2; 25 | } 26 | 27 | shape(){}; //default constructor 28 | 29 | shape(double a,double b) //parameterized constructor 30 | { 31 | dimen1=a; 32 | dimen2=b; 33 | } 34 | 35 | abstract double compute_area(); //abstract method to calculate area 36 | 37 | void read() //method to take dimensions as input from user 38 | { 39 | Scanner sc=new Scanner(System.in); 40 | System.out.print("ENTER FIRST DIMENSION : "); 41 | dimen1=sc.nextDouble(); //read dimension 1 from user 42 | System.out.print("ENTER SECOND DIMENSION : "); 43 | dimen2=sc.nextDouble(); //read dimension 2 from user 44 | } 45 | 46 | } 47 | 48 | //======================= CLASS triangle =======================// 49 | class triangle extends shape{ 50 | 51 | double area; 52 | 53 | triangle(){} //default constructor 54 | 55 | triangle(double base, double height) //parameterized constructor 56 | { 57 | super(base,height); //call to parameterized constructor of shape class 58 | } 59 | 60 | double compute_area() // method to calculate and return area of 61 | { 62 | area=(getDimen1()*getDimen2())/2; 63 | return area; 64 | } 65 | } 66 | 67 | 68 | //======================= CLASS rectangle =======================// 69 | class rectangle extends shape { 70 | 71 | double area; 72 | 73 | rectangle(){} //default constructor 74 | 75 | rectangle (double length, double breadth) //parameterized constructor 76 | { 77 | super(length,breadth); //call to parameterized constructor of shape class 78 | } 79 | 80 | double compute_area() // method to calculate and return area of rectangle 81 | { 82 | area=(getDimen1()*getDimen2()); 83 | return area; 84 | } 85 | } 86 | 87 | 88 | //======================= CLASS Main =======================// 89 | public class Main { 90 | 91 | public static void main(String args[]) //main method 92 | { 93 | Scanner sc=new Scanner(System.in); 94 | 95 | int x; //switch case variable 96 | shape s; //reference variable of super class shape 97 | do { 98 | System.out.print("\n\t MENU\n\t1.Triangle\n\t2.Rectangle \n\t3.Exit\n\tChoice ::"); 99 | 100 | x=sc.nextInt(); 101 | System.out.println(); 102 | switch(x) 103 | { 104 | case 1: //area of triangle by parameterized constructor 105 | 106 | double a,b; 107 | System.out.print("ENTER BASE OF TRIANGLE: "); 108 | a=sc.nextDouble(); //read dimension 1 from user 109 | System.out.print("ENTER HEIGHT OF TRIANGLE: "); 110 | b=sc.nextDouble(); //read dimension 2 from user 111 | 112 | triangle t= new triangle(a,b); 113 | //reference variable of shape and object type of triangle 114 | s=t; 115 | System.out.println("AREA OF TRIANGLE IS : "+ s.compute_area()); 116 | //displaying area of triangle 117 | System.out.println("======================================================="); 118 | break; 119 | 120 | 121 | case 2: //area of rectangle by default constructor 122 | 123 | rectangle r= new rectangle(); 124 | //reference variable of shape and object type of rectangle class 125 | s=r; 126 | s.read(); //call to read function 127 | System.out.println("AREA OF RECTANGLE IS : "+ s.compute_area()); 128 | System.out.println("======================================================="); 129 | break; 130 | 131 | 132 | case 3: //Exited 133 | System.out.println(" EXITED SUCCESSFULLY "); 134 | System.out.println("======================================================="); 135 | break; 136 | 137 | 138 | default: //default case 139 | System.out.println(" INVALID INPUT "); 140 | System.out.println("======================================================="); 141 | 142 | } 143 | }while(x!=3); //loop breaks when input x=3 144 | 145 | sc.close(); //closing of scanner class 146 | } 147 | } 148 | //=================================================================================================// 149 | 150 | 151 | 152 | /* 153 | ##OUTPUT## 154 | 155 | MENU 156 | 1.Triangle 157 | 2.Rectangle 158 | 3.Exit 159 | Choice ::1 160 | 161 | ENTER BASE OF TRIANGLE: 5.2 162 | ENTER HEIGHT OF TRIANGLE: 6.6 163 | AREA OF TRIANGLE IS : 17.16 164 | ======================================================= 165 | 166 | MENU 167 | 1.Triangle 168 | 2.Rectangle 169 | 3.Exit 170 | Choice ::2 171 | 172 | ENTER FIRST DIMENSION : 2.0 173 | ENTER SECOND DIMENSION : 9.7 174 | AREA OF RECTANGLE IS : 19.4 175 | ======================================================= 176 | 177 | MENU 178 | 1.Triangle 179 | 2.Rectangle 180 | 3.Exit 181 | Choice ::5 182 | 183 | INVALID INPUT 184 | ======================================================= 185 | 186 | MENU 187 | 1.Triangle 188 | 2.Rectangle 189 | 3.Exit 190 | Choice ::3 191 | 192 | EXITED SUCCESSFULLY 193 | ======================================================= 194 | 195 | */ 196 | -------------------------------------------------------------------------------- /Assignment-2/output.txt: -------------------------------------------------------------------------------- 1 | CHOOSE ONE OF THE FOLLOWING.... 2 | 3 | 1.BOOK 2.MAGAZINE 4 | 5 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 6 | 7 | 8 | Choice::1 9 | 10 | MENU FOR BOOK 11 | 1.read book 2.display 12 | 3.sale copies 4.order copies 13 | Choice::1 14 | ============================================================================== 15 | 16 | enter title : Geeta 17 | enter price: 450 18 | enter copies: 5 19 | enter author book: Vaibhav 20 | ============================================================================== 21 | 22 | Do you want to continue with book section[1/0] 23 | 1.YES 0.NO 24 | Choice::1 25 | 26 | MENU FOR BOOK 27 | 1.read book 2.display 28 | 3.sale copies 4.order copies 29 | Choice::2 30 | ============================================================================== 31 | 32 | title price copy author 33 | Geeta 450 5 Vaibhav 34 | ============================================================================== 35 | 36 | Do you want to continue with book section[1/0] 37 | 1.YES 0.NO 38 | Choice::1 39 | 40 | MENU FOR BOOK 41 | 1.read book 2.display 42 | 3.sale copies 4.order copies 43 | Choice::3 44 | ============================================================================== 45 | 46 | HOW MANY COPIES YOU(for customer) WANT : 10 47 | INSUFFICIENT STOCK!!!!!!!!! 48 | ============================================================================== 49 | 50 | Do you want to continue with book section[1/0] 51 | 1.YES 0.NO 52 | Choice::1 53 | 54 | MENU FOR BOOK 55 | 1.read book 2.display 56 | 3.sale copies 4.order copies 57 | Choice::3 58 | ============================================================================== 59 | 60 | HOW MANY COPIES YOU(for customer) WANT : 4 61 | YOU PURCHASED 4 COPIES 62 | YOU HAVE TO PAY : 1800 63 | ============================================================================== 64 | 65 | Do you want to continue with book section[1/0] 66 | 1.YES 0.NO 67 | Choice::1 68 | 69 | MENU FOR BOOK 70 | 1.read book 2.display 71 | 3.sale copies 4.order copies 72 | Choice::4 73 | ============================================================================== 74 | 75 | ENTER COPIES WANT TO ORDER(for shop): 11 76 | 77 | ORDER SUCESSFUL.... 78 | COPIES AVAILABLE : 12 79 | ============================================================================== 80 | 81 | Do you want to continue with book section[1/0] 82 | 1.YES 0.NO 83 | Choice::0 84 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 85 | 1.CONTINUE 0.TERMINATE 86 | 1 87 | 88 | 89 | CHOOSE ONE OF THE FOLLOWING.... 90 | 91 | 1.BOOK 2.MAGAZINE 92 | 93 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 94 | 95 | 96 | Choice::2 97 | 98 | MENU FOR MAGAZINE... 99 | 100 | 1.READ 2.DISPLAY 101 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 102 | 103 | 104 | Choice::1 105 | ============================================================================== 106 | 107 | enter title : TimeOfIndia 108 | enter price: 15 109 | enter copies: 20 110 | Enter THe Current Issue Date [dd/mm/yyyy]01052020 111 | ============================================================================== 112 | 113 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 114 | 1.YES 0.NO 115 | Choice::1 116 | 117 | MENU FOR MAGAZINE... 118 | 119 | 1.READ 2.DISPLAY 120 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 121 | 122 | 123 | Choice:: 124 | 2 125 | ============================================================================== 126 | 127 | title price copy date 128 | TimeOfIndia 15 20 01052020 129 | ============================================================================== 130 | 131 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 132 | 1.YES 0.NO 133 | Choice::1 134 | 135 | MENU FOR MAGAZINE... 136 | 137 | 1.READ 2.DISPLAY 138 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 139 | 140 | 141 | Choice::3 142 | ============================================================================== 143 | 144 | HOW MANY COPIES YOU WANT(customer)?? 145 | 15 146 | YOU PURCHASED 15 COPIES 147 | YOU HAVE TO PAY : 225 148 | ============================================================================== 149 | 150 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 151 | 1.YES 0.NO 152 | Choice::1 153 | 154 | MENU FOR MAGAZINE... 155 | 156 | 1.READ 2.DISPLAY 157 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 158 | 159 | 160 | Choice::4 161 | ============================================================================== 162 | 163 | ENTER THE NEW ISSUE DATE [dd/mm/yyyy]: 164 | 02072020 165 | ENTER NEW COPIES ORDERED: 166 | 5 167 | THE MAGAZINE TimeOfIndia 168 | WITH ISSUE DATE 02072020AVAILABLE 169 | ============================================================================== 170 | 171 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 172 | 1.YES 0.NO 173 | Choice::1 174 | 175 | MENU FOR MAGAZINE... 176 | 177 | 1.READ 2.DISPLAY 178 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 179 | 180 | 181 | Choice::2 182 | ============================================================================== 183 | 184 | title price copy date 185 | TimeOfIndia 15 5 02072020 186 | ============================================================================== 187 | 188 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 189 | 1.YES 0.NO 190 | Choice::0 191 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 192 | 1.CONTINUE 0.TERMINATE 193 | 1 194 | 195 | 196 | CHOOSE ONE OF THE FOLLOWING.... 197 | 198 | 1.BOOK 2.MAGAZINE 199 | 200 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 201 | 202 | 203 | Choice::3 204 | 205 | TOTAL SALE AMOUNT IS(to be paid by customer) = 2025 206 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 207 | 1.CONTINUE 0.TERMINATE 208 | 1 209 | 210 | 211 | CHOOSE ONE OF THE FOLLOWING.... 212 | 213 | 1.BOOK 2.MAGAZINE 214 | 215 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 216 | 217 | 218 | Choice::4 219 | 220 | TOTAL REVENUE OF PUBLICATION IS : 5475 221 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 222 | 1.CONTINUE 0.TERMINATE 223 | 0 224 | -------------------------------------------------------------------------------- /Assignment-6/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //Problem Statement:: 3 | /* 4 | Implement a program to handle Arithmetic exception, Array Index Out of Bounds. 5 | The user enters two numbers Num1 and Num2. The division of Num1 and Num2 is displayed. 6 | If Num1 and Num2 are not integers, the program would throw a Number Format Exception. 7 | If Num2 were zero, the program would throw an Arithmetic Exception. Display the exception. 8 | */ 9 | 10 | package assignment; 11 | import java.util.Scanner; 12 | 13 | class exception{ 14 | 15 | void arthmaticException( ) { 16 | //method to check arthmaticException 17 | Scanner sc=new Scanner(System.in);//creating object of scanner class 18 | boolean valid; 19 | valid=false;// intializing temp variable declaration 20 | while(!valid) { 21 | try { 22 | //try block 23 | System.out.println("Enter Two Numbers ::"); 24 | int num1=sc.nextInt();//taking first num as input from user 25 | int num2=sc.nextInt();//taking second num as input from user 26 | double c=num1/num2;//dividing num1 by num2 27 | System.out.println("Division is "+c);//printing result 28 | valid=true;//changing value of temp variable 29 | } 30 | catch (Exception e) { 31 | //catch block after exception occur 32 | System.out.println("\t\tCannot Divide by Zero \n\t\tEnter Valid Denominator....\n"); 33 | //printing sentence when denominator is 0 34 | } 35 | } 36 | 37 | } 38 | void ArrayOutOfBound(int [] arr) { 39 | //method to check ArrayOutOfBound 40 | Scanner sc=new Scanner(System.in);//creating object of scanner class 41 | boolean valid; 42 | valid=false;// intializing temp variable declaration 43 | while(!valid) { 44 | try { 45 | //try block 46 | System.out.print("\nEnter the Index No. of Element which you want to print ::"); 47 | int i=sc.nextInt();//taking array index from user 48 | System.out.println( arr[i]+" is present at given index"); 49 | //if index is there in array printing value at that index 50 | valid =true;//changing value of temp variable 51 | } 52 | catch(Exception e) { 53 | //catch block after exception occur 54 | System.out.println(" \t\tInvalid Index try again...\n"); 55 | //printing invalid index when index out of bound 56 | } 57 | 58 | } 59 | } 60 | 61 | void NumberFormat() { 62 | Scanner sc=new Scanner(System.in);//creating object of scanner class 63 | boolean valid=false;// intializing temp variable declaration 64 | while(!valid) { 65 | 66 | try { 67 | //try block 68 | System.out.print("Enter first number:: "); 69 | String num1=sc.next();//taking first string as input from user 70 | System.out.print("Enter Second number:: "); 71 | String num2=sc.next();//taking first string as input from user 72 | int a=Integer.parseInt(num1);//converting string to integer 73 | int b=Integer.parseInt(num2);//converting string to integer 74 | System.out.println("\nEntered Numbers are integers::"+a+" , "+b);//printing both integer to console 75 | valid=true;//changing value of temp variable 76 | 77 | } 78 | catch(Exception e){ 79 | //catch block after exception occur 80 | System.out.println("\t\tNumbers You have Enter are not Integers \n\t\tPlease try again...\n"); 81 | //printing when string is not converting to integer 82 | } 83 | 84 | } 85 | } 86 | } 87 | 88 | //======================= CLASS Main =======================// 89 | public class Main { 90 | 91 | public static void main(String[] args) { 92 | //main method to start execution of program 93 | exception e=new exception();//creating object of exception class 94 | Scanner sc=new Scanner(System.in);//creating object of scanner class 95 | int n; 96 | 97 | do { 98 | 99 | //menu driven 100 | System.out.println("\nEnter the Choice which you want to check type of error " 101 | +"\n\t\t1] Arithmaticexception" 102 | + "\t2] ArrayOutOfBound" 103 | + "\n\t\t3] NumberFormat" 104 | + "\t\t4] Exit"); 105 | 106 | n=sc.nextInt();//taking input from user 107 | //switch case 108 | switch(n) { 109 | case 1: 110 | 111 | //when input is 1 112 | e.arthmaticException();//calling arthmaticException method 113 | System.out.println("=========================================================="); 114 | break; 115 | case 2: 116 | //when input is 2 117 | int[] arr= {1,4,5,2,3,8}; 118 | e.ArrayOutOfBound(arr);//calling ArrayOutOfBound method 119 | System.out.println("=========================================================="); 120 | break; 121 | case 3: 122 | //when input is 3 123 | e.NumberFormat();//calling NumberFormat method 124 | System.out.println("=========================================================="); 125 | break; 126 | case 4: 127 | //when input is 4 128 | n=0;//setting n->0 129 | System.out.println("=========================================================="); 130 | break; 131 | default: 132 | //default when case is not found 133 | System.out.println("INVALID INPUT !!!");//printing when input is invalid 134 | System.out.println("=========================================================="); 135 | } 136 | 137 | 138 | 139 | }while(n!=0); 140 | 141 | } 142 | 143 | } 144 | 145 | 146 | /* 147 | 148 | ##OUTPUT## 149 | 150 | 151 | Enter the Choice which you want to check type of error 152 | 1] Arithmaticexception 2] ArrayOutOfBound 153 | 3] NumberFormat 4] Exit 154 | 1 155 | Enter Two Numbers :: 156 | 4 157 | 0 158 | Cannot Divide by Zero 159 | Enter Valid Denominator.... 160 | 161 | Enter Two Numbers :: 162 | 5 163 | 2 164 | Division is 2.0 165 | ========================================================== 166 | 167 | Enter the Choice which you want to check type of error 168 | 1] Arithmaticexception 2] ArrayOutOfBound 169 | 3] NumberFormat 4] Exit 170 | 2 171 | 172 | Enter the Index No. of Element which you want to print ::56 173 | Invalid Index try again... 174 | 175 | 176 | Enter the Index No. of Element which you want to print ::2 177 | 5 is present at given index 178 | ========================================================== 179 | 180 | Enter the Choice which you want to check type of error 181 | 1] Arithmaticexception 2] ArrayOutOfBound 182 | 3] NumberFormat 4] Exit 183 | 3 184 | Enter first number:: 5 185 | Enter Second number:: jk 186 | Numbers You have Enter are not Integers 187 | Please try again... 188 | 189 | Enter first number:: 6 190 | Enter Second number:: 2 191 | 192 | Entered Numbers are integers::6 , 2 193 | ========================================================== 194 | 195 | Enter the Choice which you want to check type of error 196 | 1] Arithmaticexception 2] ArrayOutOfBound 197 | 3] NumberFormat 4] Exit 198 | 4 199 | ========================================================== 200 | 201 | */ 202 | -------------------------------------------------------------------------------- /Assignment-10/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //PROBLEM STATEMENT : 3 | /* Implement a factory design pattern for the given context . Consider Car building process , 4 | * which requires many steps from allocating accessories to final makeup. These steps should 5 | * be written as methods and should be called while creating an instance of specific car type. 6 | * Hatchback, Sedan, SUV , could be the subclasses Car class. Car class and Car class its subclasses 7 | * , CarFactory and Test Factory Pattern should be implemented */ 8 | 9 | 10 | package assignment; 11 | import java.util.Scanner; 12 | // ============================= ABSTRACT CLASS Car_Factory =============================// 13 | abstract class Car_Factory{ 14 | 15 | //declaration of data member 16 | String compnay,car_name; 17 | double budget; 18 | 19 | //declaration of abstract methods 20 | abstract void getprice(double price); 21 | abstract void detail(String company_name,String car_name); 22 | abstract void accessories(); 23 | 24 | //declaration and implentation of input method 25 | void input() { 26 | Scanner scan =new Scanner (System.in);//creating object of scanner class 27 | System.out.print("Company- "); 28 | compnay=scan.next();//taking input from user 29 | System.out.print("Car- "); 30 | car_name=scan.next();//taking input from user 31 | System.out.print("Rough Budget(in Lakhs)- "); 32 | budget=scan.nextDouble();//taking input from user 33 | } 34 | void display(Car_Factory obj1) { 35 | //calling the methods// 36 | obj1.getprice(budget);//calling getprice method 37 | System.out.println("\n-----------------------------------"); 38 | obj1.detail(compnay, car_name);//calling detail method 39 | System.out.println("\n-----------------------------------"); 40 | obj1.accessories();//calling accessories method 41 | System.out.println("\n-----------------------------------"); 42 | } 43 | 44 | } 45 | 46 | //============================= CLASS Small_car =============================// 47 | class Small_car extends Car_Factory{ 48 | String Ans;//declaration of data member 49 | 50 | //method for getprice 51 | public void getprice(double price) { 52 | if(price>2&&price<5) 53 | Ans="No"; //modify Ans 54 | else 55 | Ans="Yes"; //modify Ans 56 | 57 | } 58 | //method for displaying car detail// 59 | public void detail(String company_name,String car_name) { 60 | System.out.println("Company- "+company_name); 61 | System.out.println("Name of Car- "+car_name); 62 | System.out.println("Color- Black/White/Orange/Red"); 63 | System.out.println("Fuel- Petrol"); 64 | System.out.println("Gears- Manual"); 65 | } 66 | 67 | //method to display accessories of car// 68 | public void accessories() { 69 | System.out.println("Types of Tyres- Alloy Wheels"); 70 | System.out.println("Airbags- "+Ans); 71 | System.out.println("Back Wiper- "+Ans); 72 | System.out.println("Side Mirror- Two"); 73 | System.out.println("Touch Screen Music Player- "+Ans); 74 | } 75 | } 76 | 77 | //============================= CLASS Sedan =============================// 78 | class Sedan extends Car_Factory{ 79 | String Ans;//declaration of data member 80 | 81 | //method for getprice 82 | public void getprice(double price) { 83 | if(price>6&&price<10) 84 | Ans="No"; //modify Ans 85 | else 86 | Ans="Yes"; //modify Ans 87 | } 88 | 89 | //method for displaying car detail// 90 | public void detail(String company_name,String car_name) { 91 | System.out.println("Company- "+company_name); 92 | System.out.println("Name of Car- "+car_name); 93 | System.out.println("Color- Black/White/Orange/Red"); 94 | System.out.println("Fuel- Petrol/Diesel"); 95 | System.out.println("Gears- Auto/Manual"); 96 | } 97 | //method to display accessories of car// 98 | public void accessories() { 99 | System.out.println("Types of Tyres- Alloy Wheels"); 100 | System.out.println("Airbags- YES"); 101 | System.out.println("Back Wiper- YES"); 102 | System.out.println("Side Mirror- Two"); 103 | System.out.println("Touch Screen Music Player- YES"); 104 | System.out.println("Roof Window- "+Ans); 105 | } 106 | } 107 | 108 | //============================= CLASS Small_car =============================// 109 | class Luxary extends Car_Factory{ 110 | String Ans;//declaration of data member 111 | 112 | //method for getprice 113 | public void getprice(double price) { 114 | if(price>10&&price<14) 115 | Ans="No"; //modify Ans 116 | else 117 | Ans="Yes"; //modify Ans 118 | } 119 | 120 | //method for displaying car detail// 121 | public void detail(String company_name,String car_name) { 122 | System.out.println("Company- "+company_name); 123 | System.out.println("Name of Car- "+car_name); 124 | System.out.println("Color- Black/White/Orange/Red"); 125 | System.out.println("Fuel- Diesel"); 126 | System.out.println("Gears- Auto"); 127 | } 128 | 129 | //method to display accessories of car// 130 | public void accessories() { 131 | System.out.println("Types of Tyres- Alloy Wheels"); 132 | System.out.println("Airbags- YES"); 133 | System.out.println("Back Wiper- YES"); 134 | System.out.println("Side Mirror- Two"); 135 | System.out.println("Touch Screen Music Player- YES"); 136 | System.out.println("Roof Window- YES"); 137 | System.out.println("Automotive Garbage Cans- "+Ans); 138 | System.out.println("Automotice Air Freshner- "+Ans); 139 | System.out.println("Button Start- "+Ans); 140 | } 141 | } 142 | 143 | //============================= MAIN CLASS =============================// 144 | public class Main { 145 | 146 | //ststic main method 147 | public static void main(String[] args) { 148 | // TODO Auto-generated method stub 149 | Scanner scan = new Scanner(System.in);//creating object of scanner class 150 | int ch; 151 | //double price; 152 | Car_Factory obj;// object of reference Car_Factory 153 | while(true){ 154 | //menu driven 155 | System.out.println("Which Car you want to See?- "); 156 | System.out.println("\n\t1.Small Car\n\t2.Sedan Car\n\t3.Luxary Car\n\t4.Exit"); 157 | ch=scan.nextInt();//taking input from user 158 | System.out.println(); 159 | //switch case 160 | switch(ch) { 161 | 162 | case 1: 163 | obj= new Small_car(); //creating object of Small_car 164 | obj.input();//calling input method 165 | obj.display(obj);//calling display method 166 | break; 167 | 168 | case 2: 169 | obj= new Sedan();//creating object of Sedan 170 | obj.input();//calling input method 171 | obj.display(obj);//calling display method 172 | break; 173 | 174 | case 3: 175 | obj= new Luxary();//creating object of Luxary 176 | obj.input();//calling input method 177 | obj.display(obj);//calling display method 178 | break; 179 | 180 | case 4: 181 | System.out.println("\n-----------------------------------"); 182 | return;//stop execution of program 183 | 184 | default: 185 | System.out.println("INVALID CHOICE !!");//default 186 | System.out.println("\n-----------------------------------"); 187 | break; 188 | 189 | } 190 | } 191 | } 192 | } 193 | 194 | /* 195 | 196 | ##OUTPUT## 197 | 198 | 199 | -------------------------------------- 200 | Constructing Hatchback Car 201 | -------------------------------------- 202 | Types of Tyres- Alloy Wheels 203 | Airbags- YES 204 | Back Wiper- YES 205 | Side Mirror- one 206 | Touch Screen Music Player- NO 207 | Roof Window- YES 208 | Automotive Garbage Cans- YES 209 | Automotice Air Freshner- NO 210 | Button Start- YES 211 | -------------------------------------- 212 | assignment.hatchback1@17a7cec2 213 | 214 | 215 | -------------------------------------- 216 | Constructing sedan car 217 | -------------------------------------- 218 | Types of Tyres- Alloy Wheels 219 | Airbags- YES 220 | Back Wiper- NO 221 | Side Mirror- ONE 222 | Touch Screen Music Player- YES 223 | Roof Window- YES 224 | Automotive Garbage Cans- YES 225 | Automotice Air Freshner- NO 226 | Button Start- YES 227 | -------------------------------------- 228 | assignment.sedan2@6f539caf 229 | 230 | 231 | -------------------------------------- 232 | Constructing SUV Car 233 | -------------------------------------- 234 | Types of Tyres- Alloy Wheels 235 | Airbags- YES 236 | Back Wiper- YES 237 | Side Mirror- Two 238 | Touch Screen Music Player- YES 239 | Roof Window- YES 240 | Automotive Garbage Cans- NO 241 | Automotice Air Freshner- YES 242 | Button Start- YES 243 | -------------------------------------- 244 | assignment.suv@50040f0c 245 | 246 | */ 247 | -------------------------------------------------------------------------------- /Assignment-11/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //problem Statement 3 | /* 4 | Implement and apply Strategy Design pattern for simple Shopping Cart where three payment 5 | strategies are used such as Credit Card, PayPal, Bit Coin. Create an interface for strategy pattern 6 | and give concrete implementation for payment. 7 | */ 8 | 9 | package assignment; 10 | import java.util.Scanner; 11 | 12 | //======================= INTERFACE PaymentProcessor =======================// 13 | interface PaymentProcessor { 14 | 15 | void pay(int amount);//interface method pay 16 | 17 | } 18 | 19 | //======================= CLASS CreditCard =======================// 20 | //implementing PaymentProcessor interface 21 | class CreditCard implements PaymentProcessor { 22 | Scanner sc =new Scanner (System.in);//creating object of scanner class 23 | String name,ExpDate;//declaration of name,ExpDate 24 | double CardNo;//declaration of CardNo 25 | 26 | //Constructor of CreditCard class 27 | CreditCard(){ 28 | super();//calling parent class constructor 29 | System.out.println("----------------------------------------------------------"); 30 | System.out.print("\tCard holder Name :: ");//printing on console 31 | this.name =sc.next();//taking Card holder Name as input from user 32 | System.out.print("\tCard Number :: ");//printing on console 33 | this.CardNo =sc.nextDouble();//taking Card Number as input from user 34 | System.out.print("\tCard Expire Date :: ");//printing on console 35 | this.ExpDate =sc.next();//taking Card Expire Date as input from user 36 | System.out.println("----------------------------------------------------------"); 37 | } 38 | 39 | @Override 40 | public void pay(int amount) { //method for payment 41 | System.out.println("----------------------------------------------------------"); 42 | System.out.println("Paying through CreditCard payment: Charging $" + amount); 43 | System.out.println("----------------------------------------------------------"); 44 | } 45 | 46 | 47 | } 48 | 49 | 50 | //======================= CLASS PayPal =======================// 51 | //implementing PaymentProcessor interface 52 | class PayPal implements PaymentProcessor { 53 | 54 | //Constructor of PayPal class 55 | PayPal(){ 56 | super();//calling parent class constructor 57 | System.out.println("\nChecking Internet Connection........"); 58 | } 59 | 60 | @Override 61 | public void pay(int amount) { //method for payment 62 | System.out.println("----------------------------------------------------------"); 63 | System.out.println("Paying through PayPal payment: Charging $" + amount); 64 | System.out.println("----------------------------------------------------------"); 65 | } 66 | 67 | } 68 | 69 | //======================= CLASS BitCoin =======================// 70 | //implementing PaymentProcessor interface 71 | class BitCoin implements PaymentProcessor { 72 | Scanner sc =new Scanner (System.in);//creating object of scanner class 73 | String add;//declaration of add 74 | 75 | //Constructor of BitCoin class 76 | BitCoin(){ 77 | super();//calling parent class constructor 78 | System.out.print("\nEnter Transaction 'Input Address' :: ");//asking user of address 79 | add= sc.next();//taking 'INPUT ADDRESS' as input from user 80 | 81 | } 82 | 83 | @Override 84 | public void pay(int amount) { //method for payment 85 | System.out.println("----------------------------------------------------------"); 86 | System.out.println("Paying through BitCoin payment: Charging $" + amount); 87 | System.out.println("----------------------------------------------------------"); 88 | } 89 | 90 | } 91 | 92 | 93 | //======================= CLASS Order =======================// 94 | 95 | class Order { 96 | 97 | private final PaymentProcessor paymentProcessor;//declaration of paymentProcessor object 98 | private final int amount;//declaration of amount 99 | 100 | //Order Method 101 | public Order(int amount, PaymentProcessor paymentProcessor) { 102 | this.amount = amount;//storing value 103 | this.paymentProcessor = paymentProcessor;//storing value 104 | } 105 | 106 | //process Method 107 | public void process() { 108 | paymentProcessor.pay(amount);//calling pay method 109 | } 110 | 111 | } 112 | 113 | 114 | //======================= CLASS Main =======================// 115 | public class Main { 116 | //calling static void main method 117 | public static void main(String[] args) { 118 | int c,amt=0;//declaration of c, amt 119 | Order order;//reference of order assign to order obj 120 | Scanner sc = new Scanner(System.in);//creating object of scanner class 121 | while(true) {//while loop for menu driven 122 | System.out.println(); 123 | //menu bar 124 | System.out.println("**** SHOPING CART ****"); 125 | System.out.print("1.Credit Card \n2.PayPal \n3.BitCoin \n4.Exit"); 126 | System.out.print("\n\nEnter the Choice ::"); 127 | c=sc.nextInt();//taking input from user 128 | System.out.println("----------------------------------------------------------"); 129 | if(c==1||c==2||c==3) {//check whether 0 void arr( ) { 17 | Scanner sc =new Scanner(System.in); 18 | System.out.print("Enter size of array:: "); 19 | int n=sc.nextInt();//taking size of array from user 20 | 21 | Object[] arr=new Object[n]; //creating array of size n 22 | 23 | System.out.print("Enter Array Elements :: "); 24 | for(int i =0; i void Pallindrome(T s){ 39 | String s1=(String)s; 40 | //converting s into string datatype 41 | s1=s1.toLowerCase(); 42 | //converting into lowercase letter 43 | StringBuffer sb = new StringBuffer(s1); 44 | // creating stringbuffer 45 | 46 | String ss= new String(sb.reverse()); 47 | //reversing stringbuffer and converting into string 48 | 49 | if(Objects.equals(s1, ss)) //checking both strings are equal or not 50 | System.out.println(s+" is Pallindrome");//if both string are equal 51 | else 52 | System.out.println(s+" is not Pallindrome");//if both string are different 53 | } 54 | 55 | 56 | 57 | //========================================= EVEN ODD method =========================================// 58 | 59 | public static void evenodd(T a){ 60 | if((int)a%2==0) //converting a into int and modulo by 2 61 | System.out.println(a+" is Even Number."); //if num is even 62 | 63 | else 64 | System.out.println(a+" is Odd Number."); //if num is odd 65 | } 66 | 67 | //========================================= PRIME METHOD =========================================// 68 | 69 | public static void prime(T a) { 70 | if((int)a==1) //check if a = 1 71 | System.out.println(a+" is Not Prime NNumber"); 72 | 73 | else if ((int)a==2) //check if a = 2 74 | System.out.println(a+" is Prime Number"); 75 | 76 | else if((int)a%2==0 && (int)a>2) //check if a >2 and a mod 2 =0 77 | System.out.println(a+" is Not Prime Number"); 78 | 79 | else { 80 | double b=Math.sqrt((int)a)+1; //taking squareroot of (num) +1 81 | int temp=0; // setting temp variable = 0 82 | for(int i=3;ivoid checkfun(T s) { 98 | 99 | try { 100 | //try block 101 | int b = Integer.parseInt((String) s); 102 | // try to convert "s" into integer datatype 103 | System.out.println("We can perform Pallindrome , int Array , check Prime , EvenOdd Function."); 104 | // if successfully converted, print rest of code 105 | } 106 | 107 | catch (NumberFormatException e) { 108 | //catch block 109 | // catch NumberFormateException 110 | System.out.println("We can perform Pallindrome , String Array."); 111 | } 112 | } 113 | } 114 | 115 | 116 | 117 | //========================================= MAIN CLASS =========================================// 118 | 119 | public class Main { 120 | 121 | public static void main(String[] args) { 122 | String s; // declaring s as string 123 | Scanner sc =new Scanner(System.in); // creting object of scanner class 124 | 125 | aa: //loop aa 126 | while(true) { //while loop 127 | System.out.println("\n\t==== MENU BAR ====\n\n\t1.String \n\t2.Integer" 128 | + "\n\t3.integer array \n\t4.String Array" 129 | + "\n\t5.Check Function\n\t6.Exit"); 130 | //menu bar 131 | 132 | int c =sc.nextInt();//taking input from user 133 | 134 | 135 | switch(c) {// switch cases 136 | 137 | case 1: //if input is 1 138 | System.out.print("Enter the String :: ");//printing on console 139 | s =sc.next();//taking String s as an input from user 140 | Number.Pallindrome(s); //calling Pallindrome method 141 | System.out.println("======================================================"); 142 | break; 143 | 144 | case 2: //if input is 2 145 | System.out.print("Enter the Integer :: ");//printing on console 146 | s =sc.next();//taking String s as an input from user 147 | Number.Pallindrome(s); //calling Pallindrome method 148 | Number.evenodd(Integer.parseInt(s)); //calling Even Odd method 149 | Number.prime(Integer.parseInt(s)); //calling prime method 150 | System.out.println("======================================================"); 151 | break; 152 | 153 | 154 | case 3: //if input is 3 155 | 156 | case 4: //if input is 4 157 | Number.arr();//array method 158 | System.out.println("======================================================"); 159 | break; 160 | 161 | case 5: //if input is 5 162 | System.out.print("Enter the String :: ");//printing on console 163 | String ss =sc.next();//taking String ss as an input from user 164 | Number.checkfun(ss); //calling check function method 165 | System.out.println("======================================================"); 166 | break; 167 | 168 | case 6: //if input is 6 169 | System.out.println("======================================================"); 170 | break aa; // break aa loop, stop execution of program 171 | 172 | default: //default Statement 173 | System.out.println("Invalid Input !!!"); //printing invalid input on console 174 | System.out.println("======================================================"); 175 | 176 | } 177 | } 178 | } 179 | 180 | } 181 | 182 | 183 | /* 184 | 185 | ##OUTPUT## 186 | 187 | 188 | ==== MENU BAR ==== 189 | 190 | 1.String 191 | 2.Integer 192 | 3.integer array 193 | 4.String Array 194 | 5.Check Function 195 | 6.Exit 196 | 1 197 | Enter the String :: Madam 198 | Madam is Pallindrome 199 | ====================================================== 200 | 201 | ==== MENU BAR ==== 202 | 203 | 1.String 204 | 2.Integer 205 | 3.integer array 206 | 4.String Array 207 | 5.Check Function 208 | 6.Exit 209 | 1 210 | Enter the String :: Student 211 | Student is not Pallindrome 212 | ====================================================== 213 | 214 | ==== MENU BAR ==== 215 | 216 | 1.String 217 | 2.Integer 218 | 3.integer array 219 | 4.String Array 220 | 5.Check Function 221 | 6.Exit 222 | 2 223 | Enter the Integer :: 1234321 224 | 1234321 is Pallindrome 225 | 1234321 is Odd Number. 226 | 1234321 is Not Prime Number 227 | ====================================================== 228 | 229 | ==== MENU BAR ==== 230 | 231 | 1.String 232 | 2.Integer 233 | 3.integer array 234 | 4.String Array 235 | 5.Check Function 236 | 6.Exit 237 | 2 238 | Enter the Integer :: 2 239 | 2 is Pallindrome 240 | 2 is Even Number. 241 | 2 is Prime Number 242 | ====================================================== 243 | 244 | ==== MENU BAR ==== 245 | 246 | 1.String 247 | 2.Integer 248 | 3.integer array 249 | 4.String Array 250 | 5.Check Function 251 | 6.Exit 252 | 3 253 | Enter size of array:: 4 254 | Enter Array Elements :: 4 6 2 8 255 | Entered Array is :: '4' '6' '2' '8' 256 | ====================================================== 257 | 258 | ==== MENU BAR ==== 259 | 260 | 1.String 261 | 2.Integer 262 | 3.integer array 263 | 4.String Array 264 | 5.Check Function 265 | 6.Exit 266 | 4 267 | Enter size of array:: 6 268 | Enter Array Elements :: ads xd gxdfh fgxdg gdc hfh 269 | Entered Array is :: 'ads' 'xd' 'gxdfh' 'fgxdg' 'gdc' 'hfh' 270 | ====================================================== 271 | 272 | ==== MENU BAR ==== 273 | 274 | 1.String 275 | 2.Integer 276 | 3.integer array 277 | 4.String Array 278 | 5.Check Function 279 | 6.Exit 280 | 5 281 | Enter the String :: 2446 282 | We can perform Pallindrome , int Array , check Prime , EvenOdd Function. 283 | ====================================================== 284 | 285 | ==== MENU BAR ==== 286 | 287 | 1.String 288 | 2.Integer 289 | 3.integer array 290 | 4.String Array 291 | 5.Check Function 292 | 6.Exit 293 | 5 294 | Enter the String :: parent 295 | We can perform Pallindrome , String Array. 296 | ====================================================== 297 | 298 | ==== MENU BAR ==== 299 | 300 | 1.String 301 | 2.Integer 302 | 3.integer array 303 | 4.String Array 304 | 5.Check Function 305 | 6.Exit 306 | 6 307 | ====================================================== 308 | 309 | */ 310 | -------------------------------------------------------------------------------- /Assignment-5/output.txt: -------------------------------------------------------------------------------- 1 | ====================================================================== 2 | SELECT VEHICLE 3 | 1.BICYCLE 4 | 2.CAR 5 | 3.BIKE 6 | 4.Exit 7 | Choice::1 8 | ====================================================================== 9 | Bicycle started successfully 10 | 11 | ====================================================================== 12 | Press 1. Speed Up 13 | Press 2. Change gear 14 | Press 3. Apply Brakes 15 | Press 4. Display Vehicle Status 16 | Press 5. change Vehicle /Exit 17 | Choice::1 18 | ====================================================================== 19 | 20 | Bicycles speed increased 21 | current speed is 15 22 | ====================================================================== 23 | Press 1. Speed Up 24 | Press 2. Change gear 25 | Press 3. Apply Brakes 26 | Press 4. Display Vehicle Status 27 | Press 5. change Vehicle /Exit 28 | Choice::1 29 | ====================================================================== 30 | 31 | Bicycles speed increased 32 | current speed is 20 33 | ====================================================================== 34 | Press 1. Speed Up 35 | Press 2. Change gear 36 | Press 3. Apply Brakes 37 | Press 4. Display Vehicle Status 38 | Press 5. change Vehicle /Exit 39 | Choice::2 40 | ====================================================================== 41 | which gear you want? 3 42 | Gear changed Successfully 43 | Current Gear Is 3 44 | ====================================================================== 45 | Press 1. Speed Up 46 | Press 2. Change gear 47 | Press 3. Apply Brakes 48 | Press 4. Display Vehicle Status 49 | Press 5. change Vehicle /Exit 50 | Choice::3 51 | ====================================================================== 52 | 1. DECREASE SPEED 53 | 2. STOP BICYCLE 54 | 55 | 1 56 | Speed Reduced Successfull 57 | Current speed is 15 Kmhr 58 | 59 | ====================================================================== 60 | Press 1. Speed Up 61 | Press 2. Change gear 62 | Press 3. Apply Brakes 63 | Press 4. Display Vehicle Status 64 | Press 5. change Vehicle /Exit 65 | Choice::3 66 | ====================================================================== 67 | 1. DECREASE SPEED 68 | 2. STOP BICYCLE 69 | 70 | 1 71 | Speed Reduced Successfull 72 | Current speed is 10 Kmhr 73 | 74 | ====================================================================== 75 | Press 1. Speed Up 76 | Press 2. Change gear 77 | Press 3. Apply Brakes 78 | Press 4. Display Vehicle Status 79 | Press 5. change Vehicle /Exit 80 | Choice::3 81 | ====================================================================== 82 | 1. DECREASE SPEED 83 | 2. STOP BICYCLE 84 | 85 | 2 86 | Bicycle stopped Successfully 87 | 88 | ====================================================================== 89 | Press 1. Speed Up 90 | Press 2. Change gear 91 | Press 3. Apply Brakes 92 | Press 4. Display Vehicle Status 93 | Press 5. change Vehicle /Exit 94 | Choice::4 95 | ====================================================================== 96 | YOUR BICYCLE'S SPEED IS 0 Kmhr AND GEAR IS 0 97 | ====================================================================== 98 | Press 1. Speed Up 99 | Press 2. Change gear 100 | Press 3. Apply Brakes 101 | Press 4. Display Vehicle Status 102 | Press 5. change Vehicle /Exit 103 | Choice::5 104 | ====================================================================== 105 | SELECT VEHICLE 106 | 1.BICYCLE 107 | 2.CAR 108 | 3.BIKE 109 | 4.Exit 110 | Choice::2 111 | ====================================================================== 112 | Car started successfully 113 | 114 | ====================================================================== 115 | Press 1. Speed Up 116 | Press 2. Change gear 117 | Press 3. Apply Brakes 118 | Press 4. Display Vehicle Status 119 | Press 5. change Vehicle /Exit 120 | Choice::1 121 | ====================================================================== 122 | Cars speed increased 123 | Current speed is 30 Kmhr 124 | 125 | ====================================================================== 126 | Press 1. Speed Up 127 | Press 2. Change gear 128 | Press 3. Apply Brakes 129 | Press 4. Display Vehicle Status 130 | Press 5. change Vehicle /Exit 131 | Choice::1 132 | ====================================================================== 133 | Cars speed increased 134 | Current speed is 50 Kmhr 135 | 136 | ====================================================================== 137 | Press 1. Speed Up 138 | Press 2. Change gear 139 | Press 3. Apply Brakes 140 | Press 4. Display Vehicle Status 141 | Press 5. change Vehicle /Exit 142 | Choice::2 143 | ====================================================================== 144 | which gear you want? 8 145 | Gear Out Of Range 146 | ====================================================================== 147 | Press 1. Speed Up 148 | Press 2. Change gear 149 | Press 3. Apply Brakes 150 | Press 4. Display Vehicle Status 151 | Press 5. change Vehicle /Exit 152 | Choice::2 153 | ====================================================================== 154 | which gear you want? 4 155 | Gear changed Successfully 156 | Current Gear is 4 157 | ====================================================================== 158 | Press 1. Speed Up 159 | Press 2. Change gear 160 | Press 3. Apply Brakes 161 | Press 4. Display Vehicle Status 162 | Press 5. change Vehicle /Exit 163 | Choice::3 164 | ====================================================================== 165 | 1. TO DECREASE SPEED 166 | 2. TO STOP CAR 167 | 168 | 1 169 | Speed Reduced Successfully 170 | Current Speed Is 30 kmhr 171 | 172 | ====================================================================== 173 | Press 1. Speed Up 174 | Press 2. Change gear 175 | Press 3. Apply Brakes 176 | Press 4. Display Vehicle Status 177 | Press 5. change Vehicle /Exit 178 | Choice::3 179 | ====================================================================== 180 | 1. TO DECREASE SPEED 181 | 2. TO STOP CAR 182 | 183 | 2 184 | Car stopped Successfully 185 | 186 | ====================================================================== 187 | Press 1. Speed Up 188 | Press 2. Change gear 189 | Press 3. Apply Brakes 190 | Press 4. Display Vehicle Status 191 | Press 5. change Vehicle /Exit 192 | Choice::4 193 | ====================================================================== 194 | YOUR CAR'S SPEED IS 0 Kmhr AND GEAR IS 0 195 | 196 | ====================================================================== 197 | Press 1. Speed Up 198 | Press 2. Change gear 199 | Press 3. Apply Brakes 200 | Press 4. Display Vehicle Status 201 | Press 5. change Vehicle /Exit 202 | Choice::5 203 | ====================================================================== 204 | SELECT VEHICLE 205 | 1.BICYCLE 206 | 2.CAR 207 | 3.BIKE 208 | 4.Exit 209 | Choice::3 210 | ====================================================================== 211 | Bike started successfully 212 | 213 | ====================================================================== 214 | Press 1. Speed Up 215 | Press 2. Change gear 216 | Press 3. Apply Brakes 217 | Press 4. Display Vehicle Status 218 | Press 5. change Vehicle /Exit 219 | Choice::1 220 | ====================================================================== 221 | Bike's speed increased 222 | Current speed is 30 Kmhr. 223 | 224 | ====================================================================== 225 | Press 1. Speed Up 226 | Press 2. Change gear 227 | Press 3. Apply Brakes 228 | Press 4. Display Vehicle Status 229 | Press 5. change Vehicle /Exit 230 | Choice::2 231 | ====================================================================== 232 | which gear you want? 6 233 | Gear out of range 234 | 235 | ====================================================================== 236 | Press 1. Speed Up 237 | Press 2. Change gear 238 | Press 3. Apply Brakes 239 | Press 4. Display Vehicle Status 240 | Press 5. change Vehicle /Exit 241 | Choice::2 242 | ====================================================================== 243 | which gear you want? 3 244 | Gear changed Successfully 245 | Current Gear IS 3 246 | ====================================================================== 247 | Press 1. Speed Up 248 | Press 2. Change gear 249 | Press 3. Apply Brakes 250 | Press 4. Display Vehicle Status 251 | Press 5. change Vehicle /Exit 252 | Choice::3 253 | ====================================================================== 254 | 1. TO DECREASE SPEED 255 | 2. TO STOP bike 256 | 257 | 1 258 | Speed Reduced Successfull 259 | Current speed is 10kmhr 260 | 261 | ====================================================================== 262 | Press 1. Speed Up 263 | Press 2. Change gear 264 | Press 3. Apply Brakes 265 | Press 4. Display Vehicle Status 266 | Press 5. change Vehicle /Exit 267 | Choice::4 268 | ====================================================================== 269 | YOUR BIKE'S SPEED IS 10 Kmhr AND GEAR IS 3 270 | 271 | ====================================================================== 272 | Press 1. Speed Up 273 | Press 2. Change gear 274 | Press 3. Apply Brakes 275 | Press 4. Display Vehicle Status 276 | Press 5. change Vehicle /Exit 277 | Choice::3 278 | ====================================================================== 279 | 1. TO DECREASE SPEED 280 | 2. TO STOP bike 281 | 2 282 | Bike stopped Successfully 283 | 284 | ====================================================================== 285 | Press 1. Speed Up 286 | Press 2. Change gear 287 | Press 3. Apply Brakes 288 | Press 4. Display Vehicle Status 289 | Press 5. change Vehicle /Exit 290 | Choice::5 291 | ====================================================================== 292 | SELECT VEHICLE 293 | 1.BICYCLE 294 | 2.CAR 295 | 3.BIKE 296 | 4.Exit 297 | Choice::6 298 | ====================================================================== 299 | INVALID INPUT 300 | ====================================================================== 301 | SELECT VEHICLE 302 | 1.BICYCLE 303 | 2.CAR 304 | 3.BIKE 305 | 4.Exit 306 | Choice::4 307 | ====================================================================== 308 | -------------------------------------------------------------------------------- /Assignment-9/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //problem Statement 3 | /* 4 | Using concepts of Object Oriented programming develop solution 5 | Banking solution contains following operations such as 1. Create an account 6 | 2.Deposit money 3.Withdraw money 4. Honor daily withdrawal limit 5. Check the balance 7 | 6. Display Account information. 8 | */ 9 | 10 | package assignment; 11 | import java.util.Scanner; 12 | 13 | 14 | //CUSTOMER CLASS 15 | class Customer { 16 | private String customerName; //declaration of customerName 17 | private int customerAge; //declaration of customerAge 18 | public void setCustomerName(String customerName){ 19 | this.customerName=customerName; //setting value of customerName 20 | } 21 | 22 | public String getCustomerName(){ 23 | return customerName; //returning value of customerName 24 | } 25 | 26 | public void setCustomerAge(int customerAge){ 27 | this.customerAge=customerAge; //setting value of customerAge 28 | } 29 | 30 | public int getCustomerAge(){ 31 | return customerAge; //returning value of customerAge 32 | } 33 | 34 | } 35 | 36 | abstract class Account { //creating abstract class account 37 | protected double balance; //declaration of balance 38 | protected int accountId; //declaration of accountId 39 | protected String accountType; //declaration of accountType 40 | protected Customer custobj; //declaration of customer obj 41 | 42 | void setBalance(double balance){ 43 | this.balance=balance; //setting value of balance 44 | } 45 | 46 | double getBalance(){ 47 | return balance; //returning value of balance 48 | } 49 | 50 | void setAccountId(int accountId){ 51 | this.accountId=accountId; //setting value of balance 52 | } 53 | 54 | int getAccountId(){ 55 | return accountId; //returning value of accountId 56 | } 57 | 58 | void setAccountType(String accountType){ 59 | this.accountType=accountType; //setting value of balance 60 | } 61 | 62 | String getAccountType(){ 63 | return accountType; //returning value of accountType 64 | } 65 | 66 | void setCustomerObject(Customer custobj){ 67 | this.custobj=custobj; //setting value of balance 68 | } 69 | 70 | Customer getCustomerObject(){ 71 | return custobj; //returning value of custobj 72 | } 73 | 74 | public abstract boolean withdraw(double amount); //abstract method withdraw 75 | 76 | } 77 | 78 | 79 | //SAVING ACCOUNT CLASS 80 | class SavingsAccount extends Account{ 81 | //inheriting Account class in SavingAccount 82 | private double minimumBalance; //declaration of minimumBalance 83 | public void setMinimumBalance(double minimumBalance){ 84 | this.minimumBalance=minimumBalance; //setting minimumBalance 85 | } 86 | 87 | public double getMinimumBalance(){ 88 | return minimumBalance; //returning minimumBalance 89 | } 90 | 91 | public boolean withdraw(double amount){ 92 | //method to return true or false 93 | if((balance-amount)>minimumBalance){ 94 | //check whether withdraw amount is greater than minimumBalance 95 | balance-=amount; //balance minus amount 96 | return true; //returning true 97 | } 98 | else 99 | return false; //returning false 100 | } 101 | } 102 | 103 | 104 | //BANK CLASS 105 | class Bank { 106 | public static Scanner sc=new Scanner(System.in); //creating object of scanner class 107 | public SavingsAccount a=new SavingsAccount(); // creating object of SavingAccount class 108 | public Customer c=new Customer(); //creating object of Customer class 109 | 110 | public SavingsAccount createAccount(){ //method to create an Account 111 | sc.nextLine(); 112 | 113 | System.out.print("Enter your name: "); //printing on console 114 | String customername=sc.nextLine(); //taking customername as input from user 115 | c.setCustomerName(customername); //calling setCustomerName method 116 | 117 | System.out.print("Enter your age: "); //printing on console 118 | int customerage=sc.nextInt(); //taking customerage as input from user 119 | if(customerage<18){//check whether the age is less than 18 120 | do{ 121 | System.out.print("Minimum age should be 18 to create an account.\nPlease enter valid age: "); 122 | customerage=sc.nextInt(); 123 | }while(customerage<18); //if age is less than 18 124 | } 125 | c.setCustomerAge(customerage); //calling setCustomerName method 126 | 127 | a.setCustomerObject(c);//calling setCustomerName method 128 | 129 | System.out.print("Enter your account Id: "); //printing on console 130 | int accountid=sc.nextInt(); //taking accountid as input from user 131 | a.setAccountId(accountid); //calling setAccountId method 132 | 133 | System.out.print("Enter your account type: "); //printing on console 134 | String accounttype=sc.next(); //taking accounttype as input from user 135 | a.setAccountType(accounttype); //calling setAccountType method 136 | 137 | System.out.print("Enter balance: "); //printing on console 138 | double balance=sc.nextDouble();//taking balance as input from user 139 | a.setBalance(balance);//calling setBalance method 140 | 141 | System.out.print("Enter minimum balance: "); //printing on console 142 | double minbalance=sc.nextDouble(); //taking minbalance as input from user 143 | a.setMinimumBalance(minbalance); //calling setMinimumBalance method 144 | 145 | 146 | return a; //returning saving account 147 | } 148 | 149 | 150 | void getWithdrawAmount(){ //method to withdraw amount 151 | System.out.print("Enter the amount you want to withdraw: "); //printing on console 152 | double amount=sc.nextDouble(); //taking amount as input from user 153 | if(amount>20000){ //check whether amount is greater than 20000 154 | System.out.println("Withdrawal failed. Maximum limit of withdrawal in one transaction is Rs.20000."); 155 | } 156 | else{ //if amount is less than 20000 157 | if(a.withdraw(amount)==true){ //calling withdraw method 158 | System.out.println("Withdrawal successful. Balance is: "+a.getBalance()); 159 | } 160 | else 161 | System.out.println("Sorry!!! Not enough balance"); //if not enough balance 162 | } 163 | } 164 | 165 | public void depositAmount(double amount){ //method to deposit Amount 166 | double bal=a.getBalance()+amount; //previous balance + amount 167 | a.setBalance(bal); //call setBalance method 168 | System.out.println("Amount deposited successfully. Balance is: "+a.getBalance()); 169 | } 170 | 171 | public void checkBalance(){ //method to check Balance 172 | System.out.println("Balance is: "+a.getBalance());//calling getbalance method 173 | } 174 | public void displayAccountInformation(){ //method to display Account Information 175 | System.out.println("Welcome "+c.getCustomerName()+"! Following are your account details:"); 176 | //display name of customer 177 | System.out.println("Age :"+c.getCustomerAge()); //display Age of customer 178 | System.out.println("Account Id: "+a.getAccountId()); //display Account Id of customer 179 | System.out.println("Account Type: "+a.getAccountType()); //display Account Type of customer 180 | System.out.println("Balance: "+a.getBalance()); //display Balance of customer 181 | System.out.println("Minimum balance: "+a.getMinimumBalance()); //display Minimum balance of customer 182 | } 183 | } 184 | 185 | 186 | 187 | 188 | 189 | //MAIN CLASS 190 | public class Main{ 191 | public static void main(String[] args){ 192 | Scanner sc=new Scanner(System.in); //creating object of scanner class 193 | SavingsAccount a; //cresting object of SavingsAccount class 194 | Bank bm=new Bank(); //cresting object of Bank class 195 | 196 | do{ 197 | //menu driven program 198 | System.out.println("\n\t1.Create Account\n\t2.Display Account\n\t3.Check Balance" 199 | + "\n\t4.Deposit Amount\n\t5.Withdraw Amount\n\t6.Exit"); 200 | System.out.print("Enter your choice: "); //printing on console 201 | int choice=sc.nextInt(); //taking input from user 202 | System.out.println(""); 203 | switch(choice) //switch case 204 | { 205 | case 1: 206 | a=bm.createAccount(); //calling createAccount method 207 | System.out.println("================================================="); 208 | break; 209 | case 2: 210 | bm.displayAccountInformation(); //calling displayAccountInformation method 211 | System.out.println("================================================="); 212 | break; 213 | case 3: 214 | bm.checkBalance(); //calling checkBalance method 215 | System.out.println("================================================="); 216 | break; 217 | case 4: 218 | System.out.print("Enter the amount you want to deposit: "); 219 | double amount=sc.nextDouble(); 220 | bm.depositAmount(amount); //calling depositAmount method 221 | System.out.println("================================================="); 222 | break; 223 | case 5: 224 | bm.getWithdrawAmount(); //calling getWithdrawAmount method 225 | System.out.println("================================================="); 226 | break; 227 | case 6: 228 | System.out.println("================================================="); 229 | return ; //stop execution of program 230 | default: 231 | System.out.println("INVALID INPUT !!");//printing invalid input 232 | System.out.println("================================================="); 233 | break; 234 | } 235 | 236 | }while(true); 237 | } 238 | } 239 | 240 | 241 | 242 | /* 243 | 244 | ##OUTPUT## 245 | 246 | 247 | 1.Create Account 248 | 2.Display Account 249 | 3.Check Balance 250 | 4.Deposit Amount 251 | 5.Withdraw Amount 252 | 6.Exit 253 | Enter your choice: 1 254 | 255 | 256 | Enter your name: Vaibhav 257 | Enter your age: 17 258 | Minimum age should be 18 to create an account. 259 | Please enter valid age: 19 260 | Enter your account Id: 208574521 261 | Enter your account type: Saving 262 | Enter balance: 2400 263 | Enter minimum balance: 500 264 | ================================================= 265 | 266 | 1.Create Account 267 | 2.Display Account 268 | 3.Check Balance 269 | 4.Deposit Amount 270 | 5.Withdraw Amount 271 | 6.Exit 272 | Enter your choice: 2 273 | 274 | Welcome Vaibhav! Following are your account details: 275 | Age :19 276 | Account Id: 208574521 277 | Account Type: Saving 278 | Balance: 2400.0 279 | Minimum balance: 500.0 280 | ================================================= 281 | 282 | 1.Create Account 283 | 2.Display Account 284 | 3.Check Balance 285 | 4.Deposit Amount 286 | 5.Withdraw Amount 287 | 6.Exit 288 | Enter your choice: 3 289 | 290 | Balance is: 2400.0 291 | ================================================= 292 | 293 | 1.Create Account 294 | 2.Display Account 295 | 3.Check Balance 296 | 4.Deposit Amount 297 | 5.Withdraw Amount 298 | 6.Exit 299 | Enter your choice: 4 300 | 301 | Enter the amount you want to deposit: 3600 302 | Amount deposited successfully. Balance is: 6000.0 303 | ================================================= 304 | 305 | 1.Create Account 306 | 2.Display Account 307 | 3.Check Balance 308 | 4.Deposit Amount 309 | 5.Withdraw Amount 310 | 6.Exit 311 | Enter your choice: 5 312 | 313 | Enter the amount you want to withdraw: 6000 314 | Sorry!!! Not enough balance 315 | ================================================= 316 | 317 | 318 | 1.Create Account 319 | 2.Display Account 320 | 3.Check Balance 321 | 4.Deposit Amount 322 | 5.Withdraw Amount 323 | 6.Exit 324 | Enter your choice: 5 325 | 326 | Enter the amount you want to withdraw: 5000 327 | Withdrawal successful. Balance is: 1000.0 328 | ================================================= 329 | 330 | 1.Create Account 331 | 2.Display Account 332 | 3.Check Balance 333 | 4.Deposit Amount 334 | 5.Withdraw Amount 335 | 6.Exit 336 | Enter your choice: 7 337 | 338 | INVALID INPUT !! 339 | ================================================= 340 | 341 | 1.Create Account 342 | 2.Display Account 343 | 3.Check Balance 344 | 4.Deposit Amount 345 | 5.Withdraw Amount 346 | 6.Exit 347 | Enter your choice: 6 348 | 349 | ================================================= 350 | 351 | */ 352 | -------------------------------------------------------------------------------- /Assignment-8/Main.java: -------------------------------------------------------------------------------- 1 | //Problem Statement:: 2 | /* 3 | Implement a program for maintaining a student records database using File Handling. 4 | Student has Student_id, name, Roll_no, Class, marks and address. Display the data 5 | for five students. 6 | */ 7 | 8 | package assignment; 9 | import java.io.*; 10 | import java.util.*; 11 | 12 | 13 | // ========================= FILE1 CLASS =========================// 14 | 15 | class Database { 16 | static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 17 | //creating bufferredReder class object 18 | 19 | // ---------------------- addRecords method ---------------------- // 20 | public void addRecords() throws IOException { 21 | // Create or Modify a file for Database 22 | PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("sample.txt",true))); 23 | //creating file with name sapmle.txt 24 | String studentname, address,s;//declaration of studentname , address ,s 25 | int studentid, rollno, Class;//declaration of studentid , rollno, Class 26 | float marks;//declaration of marks 27 | 28 | boolean addMore = false; //declaration of addmore 29 | do { 30 | System.out.print("\nEnter Student Name: "); //printing on console 31 | studentname = br.readLine(); //taking input from user 32 | System.out.print("Student Id: "); //printing on console 33 | studentid = Integer.parseInt(br.readLine()); //taking input from user 34 | System.out.print("Roll no: ");//printing on console 35 | rollno = Integer.parseInt(br.readLine()); //taking input from user 36 | System.out.print("Address: "); //printing on console 37 | address = br.readLine(); //taking input from user 38 | System.out.print("Class: ");//printing on console 39 | Class = Integer.parseInt(br.readLine()); //taking input from user 40 | System.out.print("Marks : "); //printing on console 41 | marks = Float.parseFloat(br.readLine()); //taking input from user 42 | pw.println(studentname+" "+studentid+" "+rollno+" "+address+" "+Class+" "+marks); 43 | //appending data into to file 44 | System.out.print("\nRecords added successfully !\n\nDo you want to add more records ? (y/n) : "); 45 | s = br.readLine();//take input from user 46 | if(s.equalsIgnoreCase("y")){ 47 | addMore = true;//modify addmore 48 | System.out.println(); 49 | } 50 | else 51 | addMore = false; //modify addmore 52 | } 53 | while(addMore); 54 | pw.close(); 55 | } 56 | 57 | // ---------------------- addRecords method ---------------------- // 58 | public void readRecords() throws IOException { 59 | try { 60 | // Open the file 61 | BufferedReader file = new BufferedReader(new FileReader("sample.txt")); 62 | String name; //declaration of string name 63 | int i=1; //intizing value of i=1 64 | 65 | // Read records from the file 66 | while((name = file.readLine()) != null) { 67 | System.out.println(name); //printing on console 68 | System.out.println(""); 69 | } file.close(); 70 | } 71 | catch(FileNotFoundException e){ //Exception handling 72 | System.out.println("\nERROR : File not Found !!!"); //printing on console 73 | } 74 | } 75 | 76 | // ---------------------- addRecords method ---------------------- // 77 | public void searchRecords() throws IOException { 78 | try { // Open the file 79 | BufferedReader file = new BufferedReader(new FileReader("sample.txt")); 80 | String name;//declaration of string name 81 | int flag=0; //intizing value of flag=0 82 | Scanner sc=new Scanner(System.in); //creating obj of scanner class 83 | System.out.print("Enter an id of the student you want to search: "); 84 | //printing on console 85 | String searchname=sc.next(); //taking input from user 86 | // Read records from the file 87 | while((name = file.readLine()) != null) { 88 | String[] line = name.split(" "); 89 | 90 | if(searchname.equalsIgnoreCase(line[1])){ 91 | System.out.println("Record found"); //printing on console 92 | System.out.println(name); //printing record on console 93 | System.out.println(""); 94 | flag=1; //modify value 95 | break; 96 | } 97 | } 98 | if(flag==0) //check condition 99 | System.out.println("Record not found"); //printing on console 100 | file.close(); //closing file 101 | } 102 | catch(FileNotFoundException e) {//Exception handling 103 | System.out.println("\nERROR : File not Found !!!");//printing on console 104 | } 105 | } 106 | 107 | // ---------------------- addRecords method ---------------------- // 108 | public void deleteRecords() throws IOException { 109 | try { // Open the file 110 | BufferedReader file1 = new BufferedReader(new FileReader("sample.txt")); 111 | PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("new.txt",true))); 112 | String name; //declaration of string name 113 | int flag=0; //intizing value of flag=0 114 | Scanner sc=new Scanner(System.in); //creating obj of scanner class 115 | System.out.print("Enter the name of the student you want to delete: "); 116 | String searchname=sc.next(); // Read records from the file 117 | while((name = file1.readLine()) != null) { 118 | String[] line = name.split(" "); 119 | if(!searchname.equalsIgnoreCase(line[0])){ 120 | pw.println(name); 121 | flag=0; //modify value 122 | } 123 | else{ 124 | System.out.println("Record found"); //printing on console 125 | flag=1;//modify value 126 | } 127 | } file1.close();//closing file 128 | pw.close(); 129 | 130 | File delName = new File("sample.txt");//creating obj of sample.txt 131 | File oldName = new File("new.txt"); //creating obj of new.txt 132 | File newName = new File("sample.txt"); //creating obj of sample.txt 133 | 134 | if(delName.delete()) 135 | System.out.println("deleted successfully"); //printing on console 136 | else 137 | System.out.println("Error");//printing on console 138 | 139 | if (oldName.renameTo(newName)) 140 | System.out.println("Renamed successfully"); //printing on console 141 | else 142 | System.out.println("Error"); //printing on console 143 | 144 | } 145 | catch(FileNotFoundException e) {//Exception handling 146 | System.out.println("\nERROR : File not Found !!!"); 147 | } 148 | } 149 | 150 | // ---------------------- addRecords method ---------------------- // 151 | public void updateRecords() throws IOException { 152 | try { 153 | // Open the file 154 | BufferedReader file1 = new BufferedReader(new FileReader("sample.txt")); 155 | PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter("new.txt",true))); 156 | String name;//declaration of string name 157 | int flag=0; //intizing flag to 0 158 | Scanner sc=new Scanner(System.in); //creating obje of scanner class 159 | System.out.print("Enter the name of the student you want to update: "); //printing on console 160 | String searchname=sc.next(); // Read records from the file 161 | 162 | while((name = file1.readLine()) != null) { //check condition 163 | String[] line = name.split(" "); 164 | 165 | if(!searchname.equalsIgnoreCase(line[0])){ //check condition 166 | pw.println(name); 167 | flag=0; //modify value of flag 168 | } 169 | else 170 | { 171 | System.out.println("Record found"); //printing on console 172 | System.out.print("Enter updated marks: "); //printing on console 173 | String up_mark=sc.next(); //taking input from user 174 | pw.println(line[0]+" "+line[1]+" "+line[2]+" "+line[3]+" "+line[4]+" "+up_mark); 175 | flag=1; //modify value of flag 176 | } 177 | } 178 | file1.close(); //closing file 179 | pw.close(); 180 | File delName = new File("sample.txt");//creating obj of sample.txt 181 | File oldName = new File("new.txt"); //creating obj of new.txt 182 | File newName = new File("sample.txt"); //creating obj of sample.txt 183 | 184 | if(delName.delete()) //check condition 185 | System.out.println("record updated successfully"); //printing on console 186 | else 187 | System.out.println("Error"); //printing on console 188 | 189 | if (oldName.renameTo(newName)) //check condition 190 | System.out.println("Renamed successfully"); //printing on console 191 | else 192 | System.out.println("Error"); //printing on console 193 | 194 | } 195 | catch(FileNotFoundException e) { //Exception handling 196 | System.out.println("\nERROR : File not Found !!!"); //printing on console 197 | } 198 | } 199 | 200 | // ---------------------- addRecords method ---------------------- // 201 | public void clear(String filename) throws IOException { 202 | // Create a blank file 203 | PrintWriter pw = new PrintWriter(new BufferedWriter(new FileWriter(filename))); 204 | pw.close(); //closing PrintWriter object 205 | System.out.println("\nAll Records cleared successfully !"); 206 | //printing on console 207 | 208 | } 209 | 210 | } 211 | 212 | // ========================= MAIN CLASS =========================// 213 | public class Main{ 214 | public static void main(String args[]) throws IOException { 215 | Database f = new Database(); //creating obj of Database class 216 | Scanner sc =new Scanner(System.in);//creating object of scanner class 217 | System.out.println(""); 218 | while(true) { 219 | //menu driven 220 | System.out.print("1. Add Records\n2. Display Records\n3. Clear All Records\n4. Search Records" 221 | + "\n5. Delete Records\n6. Update Records \n7. Exit\n\nEnter your choice : "); 222 | int choice = sc.nextInt();//taking input from user 223 | System.out.println(""); 224 | 225 | //switch Case 226 | switch(choice) { 227 | case 1: 228 | f.addRecords(); //calling addRecords method 229 | System.out.println("\n====================================================\n"); 230 | break; 231 | 232 | case 2: 233 | f.readRecords(); //calling readRecords method 234 | System.out.println("\n====================================================\n"); 235 | break; 236 | 237 | case 3: 238 | f.clear("sample.txt"); //calling clear method 239 | System.out.println("\n====================================================\n"); 240 | break; 241 | 242 | case 4: 243 | f.searchRecords(); //calling searchRecords method 244 | System.out.println("\n====================================================\n"); 245 | break; 246 | 247 | case 5: 248 | f.deleteRecords();//calling deleteRecords method 249 | System.out.println("\n====================================================\n"); 250 | break; 251 | 252 | case 6: 253 | f.updateRecords(); //calling updateRecords method 254 | System.out.println("\n====================================================\n"); 255 | break; 256 | 257 | case 7: 258 | System.out.println("\n====================================================\n"); 259 | System.exit(0);//stop execution of program 260 | break; 261 | 262 | default: 263 | System.out.println("\nInvalid Choice !"); //default case 264 | System.out.println("\n====================================================\n"); 265 | break; 266 | } 267 | } 268 | 269 | } 270 | 271 | } 272 | 273 | 274 | 275 | /* 276 | 277 | ##OUTPUT## 278 | 279 | 280 | 1. Add Records 281 | 2. Display Records 282 | 3. Clear All Records 283 | 4. Search Records 284 | 5. Delete Records 285 | 6. Update Records 286 | 7. Exit 287 | 288 | Enter your choice : 3 289 | 290 | 291 | All Records cleared successfully ! 292 | 293 | ==================================================== 294 | 295 | 1. Add Records 296 | 2. Display Records 297 | 3. Clear All Records 298 | 4. Search Records 299 | 5. Delete Records 300 | 6. Update Records 301 | 7. Exit 302 | 303 | Enter your choice : 1 304 | 305 | 306 | Enter Student Name: vaibhav 307 | Student Id: 12 308 | Roll no: 12 309 | Address: pune 310 | Class: 10 311 | Marks : 489 312 | 313 | Records added successfully ! 314 | 315 | Do you want to add more records ? (y/n) : y 316 | 317 | 318 | Enter Student Name: om 319 | Student Id: 34 320 | Roll no: 34 321 | Address: jalgaon 322 | Class: 9 323 | Marks : 479 324 | 325 | Records added successfully ! 326 | 327 | Do you want to add more records ? (y/n) : y 328 | 329 | 330 | Enter Student Name: yash 331 | Student Id: 67 332 | Roll no: 67 333 | Address: Aurangabad 334 | Class: 9 335 | Marks : 467 336 | 337 | Records added successfully ! 338 | 339 | Do you want to add more records ? (y/n) : y 340 | 341 | 342 | Enter Student Name: Diptesh 343 | Student Id: 76 344 | Roll no: 76 345 | Address: Dhule 346 | Class: 10 347 | Marks : 495 348 | 349 | Records added successfully ! 350 | 351 | Do you want to add more records ? (y/n) : y 352 | 353 | 354 | Enter Student Name: Harsh 355 | Student Id: 39 356 | Roll no: 39 357 | Address: Satara 358 | Class: 11 359 | Marks : 481 360 | 361 | Records added successfully ! 362 | 363 | Do you want to add more records ? (y/n) : n 364 | 365 | ==================================================== 366 | 367 | 1. Add Records 368 | 2. Display Records 369 | 3. Clear All Records 370 | 4. Search Records 371 | 5. Delete Records 372 | 6. Update Records 373 | 7. Exit 374 | 375 | Enter your choice : 2 376 | 377 | vaibhav 12 12 pune 10 489.0 378 | 379 | om 34 34 jalgaon 9 479.0 380 | 381 | yash 67 67 Aurangabad 9 467.0 382 | 383 | Diptesh 76 76 Dhule 10 495.0 384 | 385 | Harsh 39 39 Satara 11 481.0 386 | 387 | 388 | ==================================================== 389 | 390 | 1. Add Records 391 | 2. Display Records 392 | 3. Clear All Records 393 | 4. Search Records 394 | 5. Delete Records 395 | 6. Update Records 396 | 7. Exit 397 | 398 | Enter your choice : 4 399 | 400 | Enter an id of the student you want to search: 34 401 | Record found 402 | om 34 34 jalgaon 9 479.0 403 | 404 | 405 | ==================================================== 406 | 407 | 1. Add Records 408 | 2. Display Records 409 | 3. Clear All Records 410 | 4. Search Records 411 | 5. Delete Records 412 | 6. Update Records 413 | 7. Exit 414 | 415 | Enter your choice : 4 416 | 417 | Enter an id of the student you want to search: 66 418 | Record not found 419 | 420 | ==================================================== 421 | 422 | 1. Add Records 423 | 2. Display Records 424 | 3. Clear All Records 425 | 4. Search Records 426 | 5. Delete Records 427 | 6. Update Records 428 | 7. Exit 429 | 430 | Enter your choice : 5 431 | 432 | Enter the name of the student you want to delete: om 433 | Record found 434 | deleted successfully 435 | Renamed successfully 436 | 437 | ==================================================== 438 | 439 | 1. Add Records 440 | 2. Display Records 441 | 3. Clear All Records 442 | 4. Search Records 443 | 5. Delete Records 444 | 6. Update Records 445 | 7. Exit 446 | 447 | Enter your choice : 6 448 | 449 | Enter the name of the student you want to update: vaibhav 450 | Record found 451 | Enter updated marks: 500 452 | record updated successfully 453 | Renamed successfully 454 | 455 | ==================================================== 456 | 457 | 1. Add Records 458 | 2. Display Records 459 | 3. Clear All Records 460 | 4. Search Records 461 | 5. Delete Records 462 | 6. Update Records 463 | 7. Exit 464 | 465 | Enter your choice : 3 466 | 467 | 468 | All Records cleared successfully ! 469 | 470 | ==================================================== 471 | 472 | 1. Add Records 473 | 2. Display Records 474 | 3. Clear All Records 475 | 4. Search Records 476 | 5. Delete Records 477 | 6. Update Records 478 | 7. Exit 479 | 480 | Enter your choice : 7 481 | 482 | 483 | ==================================================== 484 | */ 485 | -------------------------------------------------------------------------------- /Assignment-2/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //Problem Statement:: 3 | /* 4 | Identify commonalities and differences between Publication, Book and Magazine classes. 5 | Title, Price, Copies are common instance variables and saleCopy is common method. 6 | The differences are, Bookclass has author and orderCopies(). 7 | Magazine Class has data members as orderQty, Current issue and method receiveNewissue().Write a program 8 | to find how many copies of the given books are ordered and display total sale of publication. 9 | */ 10 | 11 | 12 | package assignment; 13 | import java.util.*; 14 | 15 | class publication { 16 | //private data members 17 | private String title; 18 | private int price; 19 | private int copies; 20 | private int total; 21 | 22 | 23 | Scanner sc=new Scanner(System.in);//scanner class object 24 | 25 | public void settitle(String title) { 26 | //setter method for title 27 | this.title=title; 28 | } 29 | 30 | 31 | public void setcopies(int copies) { 32 | //setter method for copies 33 | this.copies=copies; 34 | } 35 | 36 | 37 | public String gettitle() { 38 | //getter method for title 39 | return title; 40 | } 41 | 42 | public int getTotal() { 43 | //getter method for price 44 | return total; 45 | } 46 | 47 | public int getCopies() { 48 | //getter method for copies 49 | return copies; 50 | } 51 | 52 | public int getprice() { 53 | return price; 54 | } 55 | 56 | 57 | void read_publ() { 58 | //read or input method for common data members of magazine and book class 59 | 60 | System.out.print("enter title : "); 61 | title=sc.next(); 62 | System.out.print("enter price: "); 63 | price=sc.nextInt(); 64 | System.out.print("enter copies: "); 65 | copies=sc.nextInt(); 66 | } 67 | 68 | void display() { 69 | //display method for common data members of book and magazine class 70 | 71 | System.out.print(title+"\t"+price+"\t"+copies); 72 | } 73 | 74 | 75 | 76 | void sale_copy(int number) { 77 | //common method to sale book or magazine and generate bill 78 | if (number <= copies) 79 | //if customer needed copies are less than available 80 | { 81 | copies=copies-number; 82 | total=total + number*price; 83 | System.out.println("\tYOU PURCHASED "+number +" COPIES \n\tYOU HAVE TO PAY : "+(price*number)); 84 | } 85 | else //if customer needs copies more than available in stock 86 | System.out.println(" INSUFFICIENT STOCK!!!!!!!!!"); 87 | } 88 | 89 | } 90 | 91 | //======================= CLASS book =======================// 92 | class book extends publication { 93 | 94 | private String author; 95 | //data member of book class only 96 | 97 | 98 | void order_copies(int number) { //increase available copies of book by ordering 99 | int x=getCopies()+number; 100 | setcopies(getCopies()+number); 101 | //as data members are private, we access them with the help of methods 102 | System.out.println("\n\tORDER SUCESSFUL...."); 103 | System.out.println("\tCOPIES AVAILABLE : "+x); 104 | } 105 | 106 | void read_book() { 107 | //method calling read method of publication class and also reading author 108 | read_publ(); 109 | System.out.print("enter author book: "); 110 | author=sc.next(); 111 | } 112 | 113 | void display_book(){ 114 | System.out.println("title \tprice \tcopy \tauthor"); 115 | display();//call to display defined in publication class 116 | System.out.println("\t"+author); 117 | } 118 | } 119 | 120 | 121 | //======================= CLASS magazine =======================// 122 | class magazine extends publication{ 123 | //magazine class is inherited from publication 124 | 125 | private int order_qty; //data members 126 | private String issue_date; 127 | 128 | void receive_issue(String new_issue_date) { 129 | //method to issue new or upgraded magazine 130 | System.out.println("ENTER NEW COPIES ORDERED: "); 131 | order_qty=sc.nextInt(); 132 | 133 | setcopies(order_qty); 134 | //setting values to copies by setter method 135 | 136 | issue_date=new_issue_date; 137 | System.out.println("\tTHE MAGAZINE "+gettitle()+" \n\t WITH ISSUE DATE "+issue_date+"AVAILABLE"); 138 | } 139 | 140 | void read_mag() { //method to read or input magazine details 141 | read_publ(); //call to read method defined in publication class 142 | System.out.print("Enter THe Current Issue Date [dd/mm/yyyy]"); 143 | issue_date=sc.next(); 144 | } 145 | 146 | void display_mag() { //display method to display 147 | System.out.println("title \tprice \tcopy \tdate"); 148 | display(); 149 | System.out.println("\t"+issue_date); 150 | } 151 | } 152 | 153 | //======================= CLASS Main =======================// 154 | public class Main { 155 | 156 | public static void main(String[] args) { 157 | Scanner sc=new Scanner(System.in); 158 | book b=new book(); 159 | magazine m=new magazine(); 160 | 161 | int outer; 162 | do { 163 | 164 | System.out.println("\n\n\tCHOOSE ONE OF THE FOLLOWING....\n\n\t1.BOOK \t\t\t2.MAGAZINE" 165 | + "\n\n\t3.TOTAL SALE AMOUNT\t4.REVENUE OF PUBLICATION\n\n"); 166 | System.out.print("Choice::"); 167 | int k=sc.nextInt(); 168 | int a; 169 | aa: 170 | 171 | if(k==1) { 172 | 173 | 174 | do { 175 | int c; 176 | System.out.print("\n\t\tMENU FOR BOOK\n"); 177 | System.out.print("\t1.read book \t\t2.display \n\t3.sale copies \t\t4.order copies"); 178 | System.out.print("\n\tChoice::"); 179 | c=sc.nextInt(); 180 | switch (c){ 181 | 182 | case 1: 183 | System.out.println("==============================================================================\n"); 184 | b.read_book(); 185 | System.out.println("==============================================================================\n"); 186 | break; 187 | case 2: 188 | System.out.println("==============================================================================\n"); 189 | b.display_book(); 190 | System.out.println("==============================================================================\n"); 191 | break; 192 | case 3: 193 | System.out.println("==============================================================================\n"); 194 | System.out.print("HOW MANY COPIES YOU(for customer) WANT : "); 195 | int n1=sc.nextInt(); 196 | b.sale_copy(n1); 197 | System.out.println("==============================================================================\n"); 198 | break; 199 | case 4: 200 | System.out.println("==============================================================================\n"); 201 | System.out.print("ENTER COPIES WANT TO ORDER(for shop): "); 202 | int n2=sc.nextInt(); 203 | b.order_copies(n2); 204 | System.out.println("==============================================================================\n"); 205 | break; 206 | default: 207 | System.out.println("invalid"); 208 | 209 | } 210 | System.out.println("Do you want to continue with book section[1/0]\n\t1.YES \t\t0.NO"); 211 | System.out.print("\tChoice::"); 212 | a=sc.nextInt(); 213 | if(a==0) 214 | break aa; 215 | 216 | }while(a==1); 217 | 218 | } 219 | 220 | else if(k==2) 221 | { 222 | 223 | 224 | mm: 225 | do { 226 | System.out.println("\n\t\tMENU FOR MAGAZINE...\n\n\t1.READ \t\t2.DISPLAY \n\t3.SALE MAGAZINE COPIES \t4.RECEIVE NEW ISSUE\n"); 227 | int d; 228 | System.out.print("\n\tChoice::"); 229 | d=sc.nextInt(); 230 | switch(d) { 231 | case 1: 232 | System.out.println("==============================================================================\n"); 233 | m.read_mag(); 234 | System.out.println("==============================================================================\n"); 235 | break; 236 | case 2: 237 | System.out.println("==============================================================================\n"); 238 | m.display_mag(); 239 | System.out.println("==============================================================================\n"); 240 | break; 241 | case 3: 242 | System.out.println("==============================================================================\n"); 243 | System.out.println("HOW MANY COPIES YOU WANT(customer)?? "); 244 | int n3=sc.nextInt(); 245 | m.sale_copy(n3); 246 | System.out.println("==============================================================================\n"); 247 | break; 248 | case 4: 249 | System.out.println("==============================================================================\n"); 250 | System.out.println("ENTER THE NEW ISSUE DATE [dd/mm/yyyy]: "); 251 | String date=sc.next(); 252 | m.receive_issue(date); 253 | System.out.println("==============================================================================\n"); 254 | break; 255 | } 256 | System.out.println("DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0]\n\t1.YES\t0.NO"); 257 | System.out.print("\tChoice::"); 258 | a=sc.nextInt(); 259 | if(a==0) 260 | break mm; 261 | 262 | }while(a==1); 263 | } 264 | 265 | else if (k==3) { 266 | System.out.println("\n\tTOTAL SALE AMOUNT IS(to be paid by customer) = "+(b.getTotal()+m.getTotal())+ " "); 267 | } 268 | 269 | else if(k==4) { 270 | System.out.println("\n\tTOTAL REVENUE OF PUBLICATION IS : "+ (b.getCopies()*b.getprice() + m.getCopies()*m.getprice())); 271 | } 272 | 273 | else 274 | System.out.println("invalid key...."); 275 | System.out.println("DO YOU WANT TO CONTINUE WITH PUBLICATION???\n\t1.CONTINUE \t0.TERMINATE"); 276 | outer=sc.nextInt(); 277 | }while(outer!=0); 278 | sc.close(); 279 | } 280 | } 281 | 282 | 283 | /* 284 | 285 | OUTPUT 286 | 287 | 288 | CHOOSE ONE OF THE FOLLOWING.... 289 | 290 | 1.BOOK 2.MAGAZINE 291 | 292 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 293 | 294 | 295 | Choice::1 296 | 297 | MENU FOR BOOK 298 | 1.read book 2.display 299 | 3.sale copies 4.order copies 300 | Choice::1 301 | ============================================================================== 302 | 303 | enter title : Geeta 304 | enter price: 450 305 | enter copies: 5 306 | enter author book: Vaibhav 307 | ============================================================================== 308 | 309 | Do you want to continue with book section[1/0] 310 | 1.YES 0.NO 311 | Choice::1 312 | 313 | MENU FOR BOOK 314 | 1.read book 2.display 315 | 3.sale copies 4.order copies 316 | Choice::2 317 | ============================================================================== 318 | 319 | title price copy author 320 | Geeta 450 5 Vaibhav 321 | ============================================================================== 322 | 323 | Do you want to continue with book section[1/0] 324 | 1.YES 0.NO 325 | Choice::1 326 | 327 | MENU FOR BOOK 328 | 1.read book 2.display 329 | 3.sale copies 4.order copies 330 | Choice::3 331 | ============================================================================== 332 | 333 | HOW MANY COPIES YOU(for customer) WANT : 10 334 | INSUFFICIENT STOCK!!!!!!!!! 335 | ============================================================================== 336 | 337 | Do you want to continue with book section[1/0] 338 | 1.YES 0.NO 339 | Choice::1 340 | 341 | MENU FOR BOOK 342 | 1.read book 2.display 343 | 3.sale copies 4.order copies 344 | Choice::3 345 | ============================================================================== 346 | 347 | HOW MANY COPIES YOU(for customer) WANT : 4 348 | YOU PURCHASED 4 COPIES 349 | YOU HAVE TO PAY : 1800 350 | ============================================================================== 351 | 352 | Do you want to continue with book section[1/0] 353 | 1.YES 0.NO 354 | Choice::1 355 | 356 | MENU FOR BOOK 357 | 1.read book 2.display 358 | 3.sale copies 4.order copies 359 | Choice::4 360 | ============================================================================== 361 | 362 | ENTER COPIES WANT TO ORDER(for shop): 11 363 | 364 | ORDER SUCESSFUL.... 365 | COPIES AVAILABLE : 12 366 | ============================================================================== 367 | 368 | Do you want to continue with book section[1/0] 369 | 1.YES 0.NO 370 | Choice::0 371 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 372 | 1.CONTINUE 0.TERMINATE 373 | 1 374 | 375 | 376 | CHOOSE ONE OF THE FOLLOWING.... 377 | 378 | 1.BOOK 2.MAGAZINE 379 | 380 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 381 | 382 | 383 | Choice::2 384 | 385 | MENU FOR MAGAZINE... 386 | 387 | 1.READ 2.DISPLAY 388 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 389 | 390 | 391 | Choice::1 392 | ============================================================================== 393 | 394 | enter title : TimeOfIndia 395 | enter price: 15 396 | enter copies: 20 397 | Enter THe Current Issue Date [dd/mm/yyyy]01052020 398 | ============================================================================== 399 | 400 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 401 | 1.YES 0.NO 402 | Choice::1 403 | 404 | MENU FOR MAGAZINE... 405 | 406 | 1.READ 2.DISPLAY 407 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 408 | 409 | 410 | Choice:: 411 | 2 412 | ============================================================================== 413 | 414 | title price copy date 415 | TimeOfIndia 15 20 01052020 416 | ============================================================================== 417 | 418 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 419 | 1.YES 0.NO 420 | Choice::1 421 | 422 | MENU FOR MAGAZINE... 423 | 424 | 1.READ 2.DISPLAY 425 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 426 | 427 | 428 | Choice::3 429 | ============================================================================== 430 | 431 | HOW MANY COPIES YOU WANT(customer)?? 432 | 15 433 | YOU PURCHASED 15 COPIES 434 | YOU HAVE TO PAY : 225 435 | ============================================================================== 436 | 437 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 438 | 1.YES 0.NO 439 | Choice::1 440 | 441 | MENU FOR MAGAZINE... 442 | 443 | 1.READ 2.DISPLAY 444 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 445 | 446 | 447 | Choice::4 448 | ============================================================================== 449 | 450 | ENTER THE NEW ISSUE DATE [dd/mm/yyyy]: 451 | 02072020 452 | ENTER NEW COPIES ORDERED: 453 | 5 454 | THE MAGAZINE TimeOfIndia 455 | WITH ISSUE DATE 02072020AVAILABLE 456 | ============================================================================== 457 | 458 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 459 | 1.YES 0.NO 460 | Choice::1 461 | 462 | MENU FOR MAGAZINE... 463 | 464 | 1.READ 2.DISPLAY 465 | 3.SALE MAGAZINE COPIES 4.RECEIVE NEW ISSUE 466 | 467 | 468 | Choice::2 469 | ============================================================================== 470 | 471 | title price copy date 472 | TimeOfIndia 15 5 02072020 473 | ============================================================================== 474 | 475 | DO YOU WANT TO CONTINUE WITH MAGAZINE SECTION [1/0] 476 | 1.YES 0.NO 477 | Choice::0 478 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 479 | 1.CONTINUE 0.TERMINATE 480 | 1 481 | 482 | 483 | CHOOSE ONE OF THE FOLLOWING.... 484 | 485 | 1.BOOK 2.MAGAZINE 486 | 487 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 488 | 489 | 490 | Choice::3 491 | 492 | TOTAL SALE AMOUNT IS(to be paid by customer) = 2025 493 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 494 | 1.CONTINUE 0.TERMINATE 495 | 1 496 | 497 | 498 | CHOOSE ONE OF THE FOLLOWING.... 499 | 500 | 1.BOOK 2.MAGAZINE 501 | 502 | 3.TOTAL SALE AMOUNT 4.REVENUE OF PUBLICATION 503 | 504 | 505 | Choice::4 506 | 507 | TOTAL REVENUE OF PUBLICATION IS : 5475 508 | DO YOU WANT TO CONTINUE WITH PUBLICATION??? 509 | 1.CONTINUE 0.TERMINATE 510 | 0 511 | 512 | 513 | 514 | */ 515 | -------------------------------------------------------------------------------- /Assignment-3/output.txt: -------------------------------------------------------------------------------- 1 | ================================================================================= 2 | MAIN MENU 3 | 4 | 1.PROGRAMMER 5 | 2.TEAM LEAD 6 | 3.ASSISTANT PROJECT MANAGER 7 | 4.PROJECT MANAGER 8 | 5.EMPLOYEE SEARCH 9 | 6.EXIT 10 | Choice::1 11 | ================================================================================= 12 | PROGRAMMER MENU ..... 13 | 1. INPUT 14 | 2. DISPLAY 15 | 3. EXIT FROM PROGRAMMER 16 | Choice::1 17 | ================================================================================= 18 | Enter the name of Employee: Vaibhav 19 | Employee ID: 1 20 | Enter Address: Jalgaon 21 | Enter Mobile No.: 8657575665 22 | BASIC PAY[30000-40000]: 35241 23 | ================================================================================= 24 | DOES DO YO HAVE DONE ANY EXTRA WORK 25 | 1. PATENT 26 | 2. OTHER BENIFICIAL WORK 27 | 3.NO 28 | Choice::1 29 | DOES DO YO HAVE DONE ANY EXTRA WORK 30 | 1. PATENT 31 | 2. OTHER BENIFICIAL WORK 32 | 3.NO 33 | Choice::3 34 | ================================================================================= 35 | Enter the name of Employee: Om 36 | Employee ID: 45 37 | Enter Address: pune 38 | Enter Mobile No.: 8657421535 39 | BASIC PAY[30000-40000]: 65241 40 | SORRY!!!!!! BASIC PAY FOR PROGRAMMER MUST BETWEEN [30000 - 40000] 41 | TRY AGAIN..... 42 | BASIC PAY[30000-40000]: 36589 43 | ================================================================================= 44 | DOES DO YO HAVE DONE ANY EXTRA WORK 45 | 1. PATENT 46 | 2. OTHER BENIFICIAL WORK 47 | 3.NO 48 | Choice::3 49 | ================================================================================= 50 | Enter the name of Employee: Yash 51 | Employee ID: 45 52 | Enter Address: Yeola 53 | Enter Mobile No.: 9856321475 54 | BASIC PAY[30000-40000]: 35000 55 | ================================================================================= 56 | DOES DO YO HAVE DONE ANY EXTRA WORK 57 | 1. PATENT 58 | 2. OTHER BENIFICIAL WORK 59 | 3.NO 60 | Choice::3 61 | ================================================================================= 62 | =================================================================================================== 63 | PROGRAMMER MENU ..... 64 | 1. INPUT 65 | 2. DISPLAY 66 | 3. EXIT FROM PROGRAMMER 67 | Choice::2 68 | ================================================================================= 69 | **************************************************************** 70 | EMP NAME ID ADDRESS MOBILE 71 | **************************************************************** 72 | Vaibhav 10002 Jalgaon 8657575665 73 | 74 | **************************************************************** 75 | BASIC PAY : 35241.0 76 | HRA : 3524.1000000000004 77 | PF : 4228.92 78 | GROSS SALARY : 41765.1 79 | NET SALARY : 37500.939 80 | **************************************************************** 81 | **************************************************************** 82 | EMP NAME ID ADDRESS MOBILE 83 | **************************************************************** 84 | Om 10003 pune 8657421535 85 | 86 | **************************************************************** 87 | BASIC PAY : 36589.0 88 | HRA : 3658.9 89 | PF : 4390.68 90 | GROSS SALARY : 40247.9 91 | NET SALARY : 35820.631 92 | **************************************************************** 93 | **************************************************************** 94 | EMP NAME ID ADDRESS MOBILE 95 | **************************************************************** 96 | Yash 10004 Yeola 9856321475 97 | 98 | **************************************************************** 99 | BASIC PAY : 35000.0 100 | HRA : 3500.0 101 | PF : 4200.0 102 | GROSS SALARY : 38500.0 103 | NET SALARY : 34265.0 104 | **************************************************************** 105 | =================================================================================================== 106 | PROGRAMMER MENU ..... 107 | 1. INPUT 108 | 2. DISPLAY 109 | 3. EXIT FROM PROGRAMMER 110 | Choice::3 111 | ================================================================================= 112 | =================================================================================================== 113 | ================================================================================= 114 | MAIN MENU 115 | 116 | 1.PROGRAMMER 117 | 2.TEAM LEAD 118 | 3.ASSISTANT PROJECT MANAGER 119 | 4.PROJECT MANAGER 120 | 5.EMPLOYEE SEARCH 121 | 6.EXIT 122 | Choice::2 123 | ================================================================================= 124 | TEAMLEAD MENU ..... 125 | 1. INPUT 126 | 2. DISPLAY 127 | 3. EXIT FROM TEAMLEAD SECTION 128 | Choice::1 129 | =================================================================================================== 130 | Enter the name of Employee: Rahul 131 | Employee ID: 42 132 | Enter Address: Parola 133 | Enter Mobile No.: 9856741235 134 | BASIC PAY [40000 - 50000] : 45236 135 | ================================================================================= 136 | DOES DO YO HAVE DONE ANY EXTRA WORK 137 | 1. PATENT 138 | 2. OTHER BENIFICIAL WORK 139 | 3.NO 140 | Choice::1 141 | DOES DO YO HAVE DONE ANY EXTRA WORK 142 | 1. PATENT 143 | 2. OTHER BENIFICIAL WORK 144 | 3.NO 145 | Choice::2 146 | DOES DO YO HAVE DONE ANY EXTRA WORK 147 | 1. PATENT 148 | 2. OTHER BENIFICIAL WORK 149 | 3.NO 150 | Choice::3 151 | ================================================================================= 152 | Enter the name of Employee: Harsh 153 | Employee ID: 36 154 | Enter Address: Satara 155 | Enter Mobile No.: 8695741253 156 | BASIC PAY [40000 - 50000] : 53241 157 | SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [40000 - 50000] 158 | TRY AGAIN..... 159 | BASIC PAY [40000 - 50000] : 45263 160 | ================================================================================= 161 | DOES DO YO HAVE DONE ANY EXTRA WORK 162 | 1. PATENT 163 | 2. OTHER BENIFICIAL WORK 164 | 3.NO 165 | Choice::3 166 | ================================================================================= 167 | Enter the name of Employee: Bhushan 168 | Employee ID: 56 169 | Enter Address: Pimpri 170 | Enter Mobile No.: 9786541236 171 | BASIC PAY [40000 - 50000] : 45260 172 | ================================================================================= 173 | DOES DO YO HAVE DONE ANY EXTRA WORK 174 | 1. PATENT 175 | 2. OTHER BENIFICIAL WORK 176 | 3.NO 177 | Choice::3 178 | ================================================================================= 179 | =================================================================================================== 180 | TEAMLEAD MENU ..... 181 | 1. INPUT 182 | 2. DISPLAY 183 | 3. EXIT FROM TEAMLEAD SECTION 184 | Choice::2 185 | =================================================================================================== 186 | **************************************************************** 187 | EMP NAME ID ADDRESS MOBILE 188 | **************************************************************** 189 | Rahul 10005 Parola 9856741235 190 | 191 | **************************************************************** 192 | BASIC PAY : 45236.0 193 | HRA : 4523.6 194 | PF : 5428.32 195 | GROSS SALARY : 54759.6 196 | NET SALARY : 49286.044 197 | **************************************************************** 198 | **************************************************************** 199 | EMP NAME ID ADDRESS MOBILE 200 | **************************************************************** 201 | Harsh 10006 Satara 8695741253 202 | 203 | **************************************************************** 204 | BASIC PAY : 45263.0 205 | HRA : 4526.3 206 | PF : 5431.5599999999995 207 | GROSS SALARY : 49789.3 208 | NET SALARY : 44312.477000000006 209 | **************************************************************** 210 | **************************************************************** 211 | EMP NAME ID ADDRESS MOBILE 212 | **************************************************************** 213 | Bhushan 10007 Pimpri 9786541236 214 | 215 | **************************************************************** 216 | BASIC PAY : 45260.0 217 | HRA : 4526.0 218 | PF : 5431.2 219 | GROSS SALARY : 49786.0 220 | NET SALARY : 44309.54 221 | **************************************************************** 222 | =================================================================================================== 223 | TEAMLEAD MENU ..... 224 | 1. INPUT 225 | 2. DISPLAY 226 | 3. EXIT FROM TEAMLEAD SECTION 227 | Choice::3 228 | =================================================================================================== 229 | =================================================================================================== 230 | ================================================================================= 231 | MAIN MENU 232 | 233 | 1.PROGRAMMER 234 | 2.TEAM LEAD 235 | 3.ASSISTANT PROJECT MANAGER 236 | 4.PROJECT MANAGER 237 | 5.EMPLOYEE SEARCH 238 | 6.EXIT 239 | Choice::3 240 | ================================================================================= 241 | ASSISTANT MANAGER MENU ..... 242 | 1. INPUT 243 | 2. DISPLAY 244 | 3. EXIT FROM ASSISTANT MANAGER 245 | Choice::1 246 | =================================================================================================== 247 | Enter the name of Employee: Priya 248 | Employee ID: 47 249 | Enter Address: Nanded 250 | Enter Mobile No.: 8695321479 251 | BASIC PAY [50000 - 60000] : 57421 252 | ================================================================================= 253 | DOES DO YO HAVE DONE ANY EXTRA WORK 254 | 1. PATENT 255 | 2. OTHER BENIFICIAL WORK 256 | 3.NO 257 | Choice::1 258 | DOES DO YO HAVE DONE ANY EXTRA WORK 259 | 1. PATENT 260 | 2. OTHER BENIFICIAL WORK 261 | 3.NO 262 | Choice::2 263 | DOES DO YO HAVE DONE ANY EXTRA WORK 264 | 1. PATENT 265 | 2. OTHER BENIFICIAL WORK 266 | 3.NO 267 | Choice::3 268 | ================================================================================= 269 | Enter the name of Employee: Sneha 270 | Employee ID: 32 271 | Enter Address: Jalgaon 272 | Enter Mobile No.: 9258746315 273 | BASIC PAY [50000 - 60000] : 63524 274 | SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [50000 - 60000] 275 | TRY AGAIN..... 276 | BASIC PAY [50000 - 60000] : 56382 277 | ================================================================================= 278 | DOES DO YO HAVE DONE ANY EXTRA WORK 279 | 1. PATENT 280 | 2. OTHER BENIFICIAL WORK 281 | 3.NO 282 | Choice::3 283 | ================================================================================= 284 | =================================================================================================== 285 | ASSISTANT MANAGER MENU ..... 286 | 1. INPUT 287 | 2. DISPLAY 288 | 3. EXIT FROM ASSISTANT MANAGER 289 | Choice::2 290 | =================================================================================================== 291 | **************************************************************** 292 | EMP NAME ID ADDRESS MOBILE 293 | **************************************************************** 294 | Priya 10008 Nanded 8695321479 295 | 296 | **************************************************************** 297 | BASIC PAY : 57421.0 298 | HRA : 5742.1 299 | PF : 6890.5199999999995 300 | GROSS SALARY : 68163.1 301 | NET SALARY : 61215.15900000001 302 | **************************************************************** 303 | **************************************************************** 304 | EMP NAME ID ADDRESS MOBILE 305 | **************************************************************** 306 | Sneha 10009 Jalgaon 9258746315 307 | 308 | **************************************************************** 309 | BASIC PAY : 56382.0 310 | HRA : 5638.200000000001 311 | PF : 6765.84 312 | GROSS SALARY : 62020.2 313 | NET SALARY : 55197.978 314 | **************************************************************** 315 | =================================================================================================== 316 | ASSISTANT MANAGER MENU ..... 317 | 1. INPUT 318 | 2. DISPLAY 319 | 3. EXIT FROM ASSISTANT MANAGER 320 | Choice::3 321 | =================================================================================================== 322 | =================================================================================================== 323 | ================================================================================= 324 | MAIN MENU 325 | 326 | 1.PROGRAMMER 327 | 2.TEAM LEAD 328 | 3.ASSISTANT PROJECT MANAGER 329 | 4.PROJECT MANAGER 330 | 5.EMPLOYEE SEARCH 331 | 6.EXIT 332 | Choice::4 333 | ================================================================================= 334 | PROJECT MANAGER MENU ..... 335 | 1. INPUT 336 | 2. DISPLAY 337 | 3. EXIT FROM PROJECT MANAGER SECTION 338 | Choice::1 339 | =================================================================================================== 340 | Enter the name of Employee: Vivek 341 | Employee ID: 53 342 | Enter Address: Pune 343 | Enter Mobile No.: 8357426935 344 | BASIC PAY [60000 - 70000] : 68532 345 | ================================================================================= 346 | DOES DO YO HAVE DONE ANY EXTRA WORK 347 | 1. PATENT 348 | 2. OTHER BENIFICIAL WORK 349 | 3.NO 350 | Choice::1 351 | DOES DO YO HAVE DONE ANY EXTRA WORK 352 | 1. PATENT 353 | 2. OTHER BENIFICIAL WORK 354 | 3.NO 355 | Choice::2 356 | DOES DO YO HAVE DONE ANY EXTRA WORK 357 | 1. PATENT 358 | 2. OTHER BENIFICIAL WORK 359 | 3.NO 360 | Choice::3 361 | ================================================================================= 362 | =================================================================================================== 363 | PROJECT MANAGER MENU ..... 364 | 1. INPUT 365 | 2. DISPLAY 366 | 3. EXIT FROM PROJECT MANAGER SECTION 367 | Choice::2 368 | =================================================================================================== 369 | **************************************************************** 370 | EMP NAME ID ADDRESS MOBILE 371 | **************************************************************** 372 | Vivek 10009 Pune 8357426935 373 | 374 | **************************************************************** 375 | BASIC PAY : 68532.0 376 | HRA : 6853.200000000001 377 | PF : 8223.84 378 | GROSS SALARY : 80385.2 379 | NET SALARY : 72092.828 380 | **************************************************************** 381 | =================================================================================================== 382 | PROJECT MANAGER MENU ..... 383 | 1. INPUT 384 | 2. DISPLAY 385 | 3. EXIT FROM PROJECT MANAGER SECTION 386 | Choice::3 387 | =================================================================================================== 388 | =================================================================================================== 389 | ================================================================================= 390 | MAIN MENU 391 | 392 | 1.PROGRAMMER 393 | 2.TEAM LEAD 394 | 3.ASSISTANT PROJECT MANAGER 395 | 4.PROJECT MANAGER 396 | 5.EMPLOYEE SEARCH 397 | 6.EXIT 398 | Choice::5 399 | ================================================================================= 400 | ENTER THE DISIGNATION OF EMPLOYEE YOU WANT TO SEARCH : programmer 401 | Enter Emplyee ID:10002 402 | EMPLOYEE FOUND 403 | **************************************************************** 404 | EMP NAME ID ADDRESS MOBILE 405 | **************************************************************** 406 | Vaibhav 10002 Jalgaon 8657575665 407 | 408 | **************************************************************** 409 | BASIC PAY : 35241.0 410 | HRA : 3524.1000000000004 411 | PF : 4228.92 412 | GROSS SALARY : 41765.1 413 | NET SALARY : 37500.939 414 | **************************************************************** 415 | EMPLOYEEE WITH ID 10002 NOT FOUND IN PROGRAMMERS 416 | EMPLOYEEE WITH ID 10002 NOT FOUND IN PROGRAMMERS 417 | =================================================================================================== 418 | ================================================================================= 419 | MAIN MENU 420 | 421 | 1.PROGRAMMER 422 | 2.TEAM LEAD 423 | 3.ASSISTANT PROJECT MANAGER 424 | 4.PROJECT MANAGER 425 | 5.EMPLOYEE SEARCH 426 | 6.EXIT 427 | Choice::5 428 | ================================================================================= 429 | ENTER THE DISIGNATION OF EMPLOYEE YOU WANT TO SEARCH : manager 430 | Enter Emplyee ID:10009 431 | EMPLOYEE FOUND 432 | **************************************************************** 433 | EMP NAME ID ADDRESS MOBILE 434 | **************************************************************** 435 | Vivek 10009 Pune 8357426935 436 | 437 | **************************************************************** 438 | BASIC PAY : 68532.0 439 | HRA : 6853.200000000001 440 | PF : 8223.84 441 | GROSS SALARY : 80385.2 442 | NET SALARY : 72092.828 443 | **************************************************************** 444 | =================================================================================================== 445 | ================================================================================= 446 | MAIN MENU 447 | 448 | 1.PROGRAMMER 449 | 2.TEAM LEAD 450 | 3.ASSISTANT PROJECT MANAGER 451 | 4.PROJECT MANAGER 452 | 5.EMPLOYEE SEARCH 453 | 6.EXIT 454 | Choice::6 455 | ================================================================================= 456 | Would you like to Exit 457 | 1.YES 458 | 2.No 459 | Choice::1 460 | -------------------------------------------------------------------------------- /Assignment-5/Main.java: -------------------------------------------------------------------------------- 1 | 2 | //Problem Statement:: 3 | /* 4 | Design and develop a context for given case study and implement an 5 | interface for Vehicles Consider the example of vehicles like bicycle, 6 | car and bike. All Vehicles have common functionalities such as Gear Change, 7 | Speed up and apply breaks. Make an interface and put all these common functionalities. 8 | Bicycle, Bike, Car classes should be implemented for all these functionalities in their 9 | own class in their own way 10 | */ 11 | 12 | package assignment; 13 | import java.util.*; 14 | 15 | interface vehicle { //vehicle interface 16 | void gear_change(int a); 17 | void speed_up(); 18 | void apply_brakes(); 19 | void display(); 20 | 21 | } 22 | 23 | //BICYCLE CLASS 24 | class bicycle implements vehicle 25 | { 26 | int gear,speed; 27 | 28 | bicycle() //default constructor for bicycle 29 | { 30 | System.out.println("\tBicycle started successfully\n "); 31 | gear=1; //gear is 1 when Cycle starts 32 | speed=10; //speed is 10 when Cycle Starts 33 | } 34 | 35 | public void gear_change(int gearex) 36 | { 37 | if(gearex<7 && gearex>0) //maximum gear for vehicle is 6 38 | { 39 | gear=gearex; 40 | System.out.println("\tGear changed Successfully \n\t Current Gear Is "+gear); 41 | } 42 | else 43 | System.out.println("Gear is Out Of Range \n"); 44 | } 45 | 46 | public void speed_up() 47 | { 48 | if((speed+5)<50 ) { //50 as maximum speed 49 | speed+=5; 50 | System.out.println("\n\tBicycles speed increased \n\t current speed is "+speed); 51 | } 52 | else 53 | System.out.println("Speed Cannot Be Increased Above 50 Kmhr\n"); 54 | } 55 | 56 | public void apply_brakes() //function to apply brakes 57 | { 58 | Scanner sc=new Scanner(System.in); 59 | int x; 60 | System.out.println("1. DECREASE SPEED\n2. STOP BICYCLE\n"); 61 | x=sc.nextInt(); 62 | 63 | if(x==1) 64 | if((speed-5)>0) // speed never be negative 65 | { 66 | speed-=5; //per apply brakes bicycles speed is reduced by 5 67 | System.out.println("Speed Reduced Successfull \n\tCurrent speed is "+speed+" Kmhr \n"); 68 | } 69 | else { 70 | speed=0; 71 | gear=0; 72 | System.out.println("Bicycle stopped Successfully\n ");} 73 | 74 | if(x==2) //to stop bicycle 75 | { 76 | speed=0; 77 | gear=0; 78 | System.out.println("Bicycle stopped Successfully\n "); 79 | } 80 | 81 | } 82 | 83 | public void display() //displays current status of bicycle 84 | { 85 | System.out.println("YOUR BICYCLE'S SPEED IS "+speed +" Kmhr AND GEAR IS "+gear); 86 | } 87 | } 88 | 89 | 90 | 91 | 92 | 93 | class car implements vehicle 94 | { 95 | int gear,speed; 96 | 97 | car() 98 | { 99 | System.out.println("\tCar started successfully\n "); 100 | gear=1; //speed when car started 101 | speed=10; //gear when car started 102 | } 103 | public void gear_change(int gearex) 104 | { 105 | if(gearex<7 && gearex >0) //maximum gear is 6 106 | { 107 | this.gear=gearex; 108 | System.out.println("\tGear changed Successfully \n\t Current Gear is "+gear); 109 | } 110 | else 111 | System.out.print(" Gear Out Of Range \n"); 112 | } 113 | 114 | public void speed_up() 115 | { 116 | 117 | if((speed+20)<150 ) //150 as maximum speed 118 | { 119 | speed+=20; 120 | System.out.println("Cars speed increased \n\t Current speed is "+speed+" Kmhr\n"); 121 | } 122 | else 123 | System.out.println("Speed Cannot Be Increased Above 150 Kmhr\n"); 124 | 125 | } 126 | 127 | public void apply_brakes() 128 | { 129 | Scanner sc=new Scanner(System.in); 130 | int x; 131 | System.out.println("1. TO DECREASE SPEED\n2. TO STOP CAR\n"); 132 | x=sc.nextInt(); 133 | if(x==1) 134 | if((speed-20)>0) //checks speed is negative or positive if reduced by 20 135 | { 136 | speed-=20; //per apply brakes vehicle speed is reduced by 20 137 | System.out.println("Speed Reduced Successfully \n\tCurrent Speed Is "+speed+" kmhr\n"); 138 | } 139 | else { 140 | speed=0; 141 | gear=0; 142 | System.out.println("Car stopped Successfully\n ");} 143 | if(x==2) 144 | { 145 | speed=0; 146 | gear=0; 147 | System.out.println("Car stopped Successfully \n"); 148 | } 149 | } 150 | 151 | public void display() //displays current status of car 152 | { 153 | System.out.println("YOUR CAR'S SPEED IS "+speed +" Kmhr AND GEAR IS "+gear+"\n"); 154 | } 155 | 156 | } 157 | 158 | 159 | //BIKE CLASS 160 | 161 | class bike implements vehicle 162 | { 163 | int gear,speed; //data members of bike class 164 | 165 | bike() 166 | { 167 | System.out.println("\tBike started successfully \n"); 168 | gear=1; //initial gear when bike starts 169 | speed=10; //initial speed of bike when starts 170 | } 171 | public void gear_change(int gearex) 172 | { 173 | if(gearex<6 && gearex>0) //maximum gears is 5 174 | { 175 | gear=gearex; 176 | System.out.println("\tGear changed Successfully \n\t Current Gear IS "+gear); 177 | } 178 | else 179 | System.out.println("Gear out of range \n"); 180 | } 181 | 182 | public void speed_up() 183 | { 184 | if((speed+20)<100 ) //maximum speed is 100 for bike 185 | { 186 | speed+=20; 187 | System.out.println("Bike's speed increased \n\t Current speed is "+speed+" Kmhr.\n"); 188 | } 189 | else 190 | System.out.println("Speed Cannot Be Increased Above 100 Kmhr \n"); 191 | 192 | } 193 | 194 | public void apply_brakes() //method to reduce bike speed or stop bike 195 | { 196 | Scanner sc=new Scanner(System.in); 197 | int x; 198 | System.out.println("1. TO DECREASE SPEED\n2. TO STOP bike\n"); 199 | x=sc.nextInt(); 200 | if(x==1) 201 | if((speed-20)>0) //checks speed is negative or positive if reduced by 20 202 | { 203 | speed-=20; //per apply brakes vehicle speed is reduced by 20 204 | System.out.println("Speed Reduced Successfull \n\tCurrent speed is "+speed+ "kmhr\n" ); 205 | } 206 | else { 207 | speed=0; 208 | gear=0; 209 | System.out.println("Bike stopped Successfully \n");} 210 | if(x==2) 211 | { 212 | speed=0; 213 | gear=0; 214 | System.out.println("Bike stopped Successfully \n"); 215 | } 216 | 217 | } 218 | 219 | public void display() //displays current bike status 220 | { 221 | System.out.println("YOUR BIKE'S SPEED IS "+speed +" Kmhr AND GEAR IS "+gear+"\n"); 222 | } 223 | } 224 | 225 | //--------------------- Class Main ---------------------// 226 | public class Main { 227 | 228 | public static void main(String[] args) { 229 | // TODO Auto-generated method stub 230 | Scanner sc=new Scanner(System.in); 231 | 232 | vehicle v=null; // vehicle interface reference created 233 | System.out.println("======================================================================"); 234 | int y; //variable to choose vehicle 235 | bb: //label for do while loop 236 | do { 237 | System.out.print(" SELECT VEHICLE \n\t1.BICYCLE \n\t2.CAR \n\t3.BIKE \n\t4.Exit \nChoice::"); 238 | y=sc.nextInt(); 239 | 240 | System.out.println("======================================================================"); 241 | 242 | if(y==1) 243 | v=new bicycle(); //object of bicycle class 244 | else if(y==2) 245 | v= new car(); //object of car class 246 | else if(y==3) 247 | v=new bike(); //object of bike class 248 | else if(y==4) 249 | break bb; //label break 250 | else 251 | System.out.println("INVALID INPUT"); 252 | System.out.println("======================================================================"); 253 | 254 | if(040000 || basic_pay<30000) { 105 | //validation for basic_pay of Programmer 106 | System.out.println("SORRY!!!!!! BASIC PAY FOR PROGRAMMER MUST BETWEEN [30000 - 40000] \nTRY AGAIN....."); 107 | a=false; 108 | } 109 | else 110 | a=true; 111 | } 112 | 113 | System.out.println("================================================================================="); 114 | } 115 | 116 | static void search(Programmer arr[],int key,int n) { 117 | //search for programmer in database 118 | for(int i=0;i50000 || basic_pay<40000) { 145 | //validation for basic pay of Teamlead 146 | System.out.println("SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [40000 - 50000] \nTRY AGAIN....."); 147 | a=false; 148 | } 149 | else 150 | a=true; 151 | } 152 | System.out.println("================================================================================="); 153 | } 154 | 155 | static void search(Teamlead arr[],int key,int n) { 156 | //searching for teamlead in database 157 | for(int i=0;i60000 || basic_pay<50000) { 184 | //validation for basic pay of Asst_pro_manager 185 | System.out.println("SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [50000 - 60000] \nTRY AGAIN....."); 186 | a=false; 187 | } 188 | else 189 | a=true; 190 | } 191 | System.out.println("================================================================================="); 192 | } 193 | 194 | static void search(Asst_pro_manager arr[],int key,int n) { 195 | //searching for Asst_pro_manager in database 196 | for(int i=0;i70000 || basic_pay<60000) { 222 | //validation for basic pay of pro_manager 223 | System.out.println("SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [60000 - 70000] \nTRY AGAIN....."); 224 | a=false; 225 | } 226 | else 227 | a=true; 228 | } 229 | System.out.println("================================================================================="); 230 | } 231 | 232 | static void search(Pro_manager arr,int key) { 233 | //searching for pro_manager in database 234 | if (arr.emp_id==key) { 235 | System.out.println(" EMPLOYEE FOUND "); 236 | //if pro_manager found in database 237 | arr.display();//dispay database for Pro_manager 238 | arr.salary_slip();//printing salary slip 239 | } 240 | else { 241 | //if pro_manager is not found in database 242 | System.out.println(" EMPLOYEEE WITH ID "+ key +" NOT FOUND IN TEAMLEAD "); 243 | } 244 | } 245 | } 246 | 247 | //************************ CLASS MAIN ************************// 248 | 249 | public class Main { 250 | public static void main(String[] args) { 251 | Scanner sc=new Scanner(System.in); 252 | Programmer p[]=new Programmer[3]; 253 | //array of obj for Programmer 254 | Teamlead t[]=new Teamlead[3]; 255 | //array of obj for Teamlead 256 | Asst_pro_manager a[]=new Asst_pro_manager[2]; 257 | //array of obj for Asst_pro_manager 258 | Pro_manager m=new Pro_manager(); 259 | //array of obj for Pro_manager 260 | aa: 261 | do { 262 | //menu driven program 263 | System.out.println("================================================================================="); 264 | System.out.println(" MAIN MENU \n\n1.PROGRAMMER \n2.TEAM LEAD \n3.ASSISTANT PROJECT MANAGER \n4.PROJECT MANAGER \n5.EMPLOYEE SEARCH \n6.EXIT"); 265 | System.out.print("Choice::"); 266 | int k=sc.nextInt();//input choice from user 267 | System.out.println("================================================================================="); 268 | int op; 269 | int assign1=0,assign2=0,assign3=0,assign4=0; 270 | //variable to check memory is allocated or not for each class 271 | switch(k) { 272 | 273 | case 1://if input from user is 1 274 | do { 275 | System.out.print("\tPROGRAMMER MENU .....\n\t1. INPUT \n\t2. DISPLAY \n\t3. EXIT FROM PROGRAMMER \n\tChoice::"); 276 | op=sc.nextInt(); 277 | //input choice from user 278 | System.out.println("================================================================================="); 279 | if(op==1)//if input from user is 1 280 | { 281 | assign1=6; 282 | for (int i=0;i<3;i++) { 283 | p[i]=new Programmer(); 284 | //creating object of Programmer 285 | p[i].read_programmer(); 286 | //taking input for Programmer 287 | p[i].salary(); 288 | //printing salary of Programmer 289 | } 290 | } 291 | else if(op==2 && assign1==6) 292 | { 293 | for (int i=0;i<3;i++) { 294 | p[i].display(); 295 | //display database for programmer 296 | p[i].salary_slip(); 297 | //printing salary slip of Programmer 298 | } 299 | } 300 | else if(op==2 && assign1!=6) 301 | System.out.println(" MEMORY NOT ALLOCATED TO PROGRAMMERS DETAIL YET... "); 302 | 303 | System.out.println("==================================================================================================="); 304 | }while(op!=3); 305 | break; 306 | 307 | case 2://if input from user is 2 308 | do { 309 | System.out.print("\tTEAMLEAD MENU .....\n\t1. INPUT \n\t2. DISPLAY \n\t3. EXIT FROM TEAMLEAD SECTION \n\tChoice::"); 310 | op=sc.nextInt(); 311 | System.out.println("==================================================================================================="); 312 | if(op==1) 313 | { 314 | assign2=4; 315 | for (int i=0;i<3;i++) { 316 | t[i]=new Teamlead(); 317 | //creating object of teamlead 318 | t[i].read_teamlead(); 319 | //taking input for teamlead 320 | t[i].salary(); 321 | //printing salary of teamlead 322 | } 323 | } 324 | else if(op==2 && assign2==4) 325 | { 326 | for (int i=0;i<3;i++) { 327 | t[i].display(); 328 | //display database for teamlead 329 | t[i].salary_slip(); 330 | //printing salary slip of teamlead 331 | } 332 | } 333 | else if(op==2 && assign1!=6) 334 | System.out.println(" MEMORY NOT ALLOCATED TO TEAMLEADS DETAIL YET... "); 335 | System.out.println("==================================================================================================="); 336 | }while(op!=3); 337 | break; 338 | 339 | case 3://if input from user is 3 340 | do { 341 | System.out.print("\tASSISTANT MANAGER MENU .....\n\t1. INPUT \n\t2. DISPLAY \n\t3. EXIT FROM ASSISTANT MANAGER \n\tChoice::"); 342 | op=sc.nextInt(); 343 | System.out.println("==================================================================================================="); 344 | if(op==1) 345 | { 346 | assign3=2; 347 | for (int i=0;i<2;i++) { 348 | a[i]=new Asst_pro_manager(); 349 | //creating object of Assistant_Manager 350 | a[i].read_Asst_pro_manager(); 351 | //taking input for Assistant_Manager 352 | a[i].salary(); 353 | //printing salary of Assistant_Manager 354 | } 355 | } 356 | else if(op==2 && assign3==2) 357 | { 358 | for (int i=0;i<2;i++) { 359 | a[i].display(); 360 | //display database for Assistant_Manager 361 | a[i].salary_slip(); 362 | //printing salary slip of Assistant_Manager 363 | } 364 | } 365 | else if(op==2 && assign1!=6) System.out.println(" MEMORY NOT ALLOCATED TO PROGRAMMERS DETAIL YET... "); 366 | System.out.println("==================================================================================================="); 367 | }while(op!=3); 368 | break; 369 | 370 | case 4://if input from user is 4 371 | do { 372 | System.out.print("\tPROJECT MANAGER MENU .....\n\t1. INPUT \n\t2. DISPLAY \n\t3. EXIT FROM PROJECT MANAGER SECTION \n\tChoice::"); 373 | op=sc.nextInt(); 374 | System.out.println("==================================================================================================="); 375 | if(op==1) 376 | { 377 | assign4=1; 378 | m.read_Pro_manager(); 379 | //taking input for Project_Manager 380 | m.salary(); 381 | //printing salary of Project_Manager 382 | } 383 | else if(op==2 && assign4==1) 384 | { 385 | m.display(); 386 | //display database for Project_Manager 387 | m.salary_slip(); 388 | //printing salary slip of Project_Manager 389 | } 390 | else if(op==2 && assign1!=6) System.out.println(" MEMORY NOT ALLOCATED TO PROGRAMMERS DETAIL YET... "); 391 | System.out.println("==================================================================================================="); 392 | }while(op!=3); 393 | break; 394 | 395 | case 5://if input from user is 5 396 | String des; 397 | int key; 398 | System.out.print("ENTER THE DISIGNATION OF EMPLOYEE YOU WANT TO SEARCH : "); 399 | des=sc.next(); 400 | //taking input from user 401 | System.out.print("Enter Emplyee ID:"); 402 | key=sc.nextInt(); 403 | //taking Emplyee ID from user 404 | if(des.toLowerCase().equals("programmer")) 405 | { 406 | //searching for programmer in database 407 | Programmer.search(p,key,6); 408 | } 409 | else if(des.toLowerCase().equals("teamlead")) 410 | { 411 | //searching for teamlead in database 412 | Teamlead.search(t, key, 4); 413 | } 414 | else if(des.toLowerCase().equals("assistant")) 415 | { 416 | //searching for assistant in database 417 | Asst_pro_manager.search(a, key, 2); 418 | } 419 | else if(des.toLowerCase().equals("manager")) 420 | { 421 | //searching for manager in database 422 | Pro_manager.search(m, key); 423 | 424 | } 425 | else { 426 | //if invalid input 427 | System.out.println("INVALID INPUT"); 428 | } 429 | System.out.println("==================================================================================================="); 430 | break; 431 | 432 | case 6://if input from user is 6 433 | System.out.print("Would you like to Exit\n\t1.YES\n\t2.No\n\tChoice::"); 434 | int temp=sc.nextInt(); 435 | if(temp==1)//checking for breaking loop 436 | break aa;//breaking menu bar 437 | 438 | default://default 439 | System.out.println(" INVALID "); 440 | } 441 | 442 | }while(true); 443 | sc.close();//closing scanner class object 444 | } 445 | } 446 | 447 | 448 | //********************************************************************// 449 | 450 | 451 | 452 | /* 453 | 454 | 455 | ## Output ## 456 | 457 | ================================================================================= 458 | MAIN MENU 459 | 460 | 1.PROGRAMMER 461 | 2.TEAM LEAD 462 | 3.ASSISTANT PROJECT MANAGER 463 | 4.PROJECT MANAGER 464 | 5.EMPLOYEE SEARCH 465 | 6.EXIT 466 | Choice::1 467 | ================================================================================= 468 | PROGRAMMER MENU ..... 469 | 1. INPUT 470 | 2. DISPLAY 471 | 3. EXIT FROM PROGRAMMER 472 | Choice::1 473 | ================================================================================= 474 | Enter the name of Employee: Vaibhav 475 | Employee ID: 1 476 | Enter Address: Jalgaon 477 | Enter Mobile No.: 8657575665 478 | BASIC PAY[30000-40000]: 35241 479 | ================================================================================= 480 | DOES DO YO HAVE DONE ANY EXTRA WORK 481 | 1. PATENT 482 | 2. OTHER BENIFICIAL WORK 483 | 3.NO 484 | Choice::1 485 | DOES DO YO HAVE DONE ANY EXTRA WORK 486 | 1. PATENT 487 | 2. OTHER BENIFICIAL WORK 488 | 3.NO 489 | Choice::3 490 | ================================================================================= 491 | Enter the name of Employee: Om 492 | Employee ID: 45 493 | Enter Address: pune 494 | Enter Mobile No.: 8657421535 495 | BASIC PAY[30000-40000]: 65241 496 | SORRY!!!!!! BASIC PAY FOR PROGRAMMER MUST BETWEEN [30000 - 40000] 497 | TRY AGAIN..... 498 | BASIC PAY[30000-40000]: 36589 499 | ================================================================================= 500 | DOES DO YO HAVE DONE ANY EXTRA WORK 501 | 1. PATENT 502 | 2. OTHER BENIFICIAL WORK 503 | 3.NO 504 | Choice::3 505 | ================================================================================= 506 | Enter the name of Employee: Yash 507 | Employee ID: 45 508 | Enter Address: Yeola 509 | Enter Mobile No.: 9856321475 510 | BASIC PAY[30000-40000]: 35000 511 | ================================================================================= 512 | DOES DO YO HAVE DONE ANY EXTRA WORK 513 | 1. PATENT 514 | 2. OTHER BENIFICIAL WORK 515 | 3.NO 516 | Choice::3 517 | ================================================================================= 518 | =================================================================================================== 519 | PROGRAMMER MENU ..... 520 | 1. INPUT 521 | 2. DISPLAY 522 | 3. EXIT FROM PROGRAMMER 523 | Choice::2 524 | ================================================================================= 525 | **************************************************************** 526 | EMP NAME ID ADDRESS MOBILE 527 | **************************************************************** 528 | Vaibhav 10002 Jalgaon 8657575665 529 | 530 | **************************************************************** 531 | BASIC PAY : 35241.0 532 | HRA : 3524.1000000000004 533 | PF : 4228.92 534 | GROSS SALARY : 41765.1 535 | NET SALARY : 37500.939 536 | **************************************************************** 537 | **************************************************************** 538 | EMP NAME ID ADDRESS MOBILE 539 | **************************************************************** 540 | Om 10003 pune 8657421535 541 | 542 | **************************************************************** 543 | BASIC PAY : 36589.0 544 | HRA : 3658.9 545 | PF : 4390.68 546 | GROSS SALARY : 40247.9 547 | NET SALARY : 35820.631 548 | **************************************************************** 549 | **************************************************************** 550 | EMP NAME ID ADDRESS MOBILE 551 | **************************************************************** 552 | Yash 10004 Yeola 9856321475 553 | 554 | **************************************************************** 555 | BASIC PAY : 35000.0 556 | HRA : 3500.0 557 | PF : 4200.0 558 | GROSS SALARY : 38500.0 559 | NET SALARY : 34265.0 560 | **************************************************************** 561 | =================================================================================================== 562 | PROGRAMMER MENU ..... 563 | 1. INPUT 564 | 2. DISPLAY 565 | 3. EXIT FROM PROGRAMMER 566 | Choice::3 567 | ================================================================================= 568 | =================================================================================================== 569 | ================================================================================= 570 | MAIN MENU 571 | 572 | 1.PROGRAMMER 573 | 2.TEAM LEAD 574 | 3.ASSISTANT PROJECT MANAGER 575 | 4.PROJECT MANAGER 576 | 5.EMPLOYEE SEARCH 577 | 6.EXIT 578 | Choice::2 579 | ================================================================================= 580 | TEAMLEAD MENU ..... 581 | 1. INPUT 582 | 2. DISPLAY 583 | 3. EXIT FROM TEAMLEAD SECTION 584 | Choice::1 585 | =================================================================================================== 586 | Enter the name of Employee: Rahul 587 | Employee ID: 42 588 | Enter Address: Parola 589 | Enter Mobile No.: 9856741235 590 | BASIC PAY [40000 - 50000] : 45236 591 | ================================================================================= 592 | DOES DO YO HAVE DONE ANY EXTRA WORK 593 | 1. PATENT 594 | 2. OTHER BENIFICIAL WORK 595 | 3.NO 596 | Choice::1 597 | DOES DO YO HAVE DONE ANY EXTRA WORK 598 | 1. PATENT 599 | 2. OTHER BENIFICIAL WORK 600 | 3.NO 601 | Choice::2 602 | DOES DO YO HAVE DONE ANY EXTRA WORK 603 | 1. PATENT 604 | 2. OTHER BENIFICIAL WORK 605 | 3.NO 606 | Choice::3 607 | ================================================================================= 608 | Enter the name of Employee: Harsh 609 | Employee ID: 36 610 | Enter Address: Satara 611 | Enter Mobile No.: 8695741253 612 | BASIC PAY [40000 - 50000] : 53241 613 | SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [40000 - 50000] 614 | TRY AGAIN..... 615 | BASIC PAY [40000 - 50000] : 45263 616 | ================================================================================= 617 | DOES DO YO HAVE DONE ANY EXTRA WORK 618 | 1. PATENT 619 | 2. OTHER BENIFICIAL WORK 620 | 3.NO 621 | Choice::3 622 | ================================================================================= 623 | Enter the name of Employee: Bhushan 624 | Employee ID: 56 625 | Enter Address: Pimpri 626 | Enter Mobile No.: 9786541236 627 | BASIC PAY [40000 - 50000] : 45260 628 | ================================================================================= 629 | DOES DO YO HAVE DONE ANY EXTRA WORK 630 | 1. PATENT 631 | 2. OTHER BENIFICIAL WORK 632 | 3.NO 633 | Choice::3 634 | ================================================================================= 635 | =================================================================================================== 636 | TEAMLEAD MENU ..... 637 | 1. INPUT 638 | 2. DISPLAY 639 | 3. EXIT FROM TEAMLEAD SECTION 640 | Choice::2 641 | =================================================================================================== 642 | **************************************************************** 643 | EMP NAME ID ADDRESS MOBILE 644 | **************************************************************** 645 | Rahul 10005 Parola 9856741235 646 | 647 | **************************************************************** 648 | BASIC PAY : 45236.0 649 | HRA : 4523.6 650 | PF : 5428.32 651 | GROSS SALARY : 54759.6 652 | NET SALARY : 49286.044 653 | **************************************************************** 654 | **************************************************************** 655 | EMP NAME ID ADDRESS MOBILE 656 | **************************************************************** 657 | Harsh 10006 Satara 8695741253 658 | 659 | **************************************************************** 660 | BASIC PAY : 45263.0 661 | HRA : 4526.3 662 | PF : 5431.5599999999995 663 | GROSS SALARY : 49789.3 664 | NET SALARY : 44312.477000000006 665 | **************************************************************** 666 | **************************************************************** 667 | EMP NAME ID ADDRESS MOBILE 668 | **************************************************************** 669 | Bhushan 10007 Pimpri 9786541236 670 | 671 | **************************************************************** 672 | BASIC PAY : 45260.0 673 | HRA : 4526.0 674 | PF : 5431.2 675 | GROSS SALARY : 49786.0 676 | NET SALARY : 44309.54 677 | **************************************************************** 678 | =================================================================================================== 679 | TEAMLEAD MENU ..... 680 | 1. INPUT 681 | 2. DISPLAY 682 | 3. EXIT FROM TEAMLEAD SECTION 683 | Choice::3 684 | =================================================================================================== 685 | =================================================================================================== 686 | ================================================================================= 687 | MAIN MENU 688 | 689 | 1.PROGRAMMER 690 | 2.TEAM LEAD 691 | 3.ASSISTANT PROJECT MANAGER 692 | 4.PROJECT MANAGER 693 | 5.EMPLOYEE SEARCH 694 | 6.EXIT 695 | Choice::3 696 | ================================================================================= 697 | ASSISTANT MANAGER MENU ..... 698 | 1. INPUT 699 | 2. DISPLAY 700 | 3. EXIT FROM ASSISTANT MANAGER 701 | Choice::1 702 | =================================================================================================== 703 | Enter the name of Employee: Priya 704 | Employee ID: 47 705 | Enter Address: Nanded 706 | Enter Mobile No.: 8695321479 707 | BASIC PAY [50000 - 60000] : 57421 708 | ================================================================================= 709 | DOES DO YO HAVE DONE ANY EXTRA WORK 710 | 1. PATENT 711 | 2. OTHER BENIFICIAL WORK 712 | 3.NO 713 | Choice::1 714 | DOES DO YO HAVE DONE ANY EXTRA WORK 715 | 1. PATENT 716 | 2. OTHER BENIFICIAL WORK 717 | 3.NO 718 | Choice::2 719 | DOES DO YO HAVE DONE ANY EXTRA WORK 720 | 1. PATENT 721 | 2. OTHER BENIFICIAL WORK 722 | 3.NO 723 | Choice::3 724 | ================================================================================= 725 | Enter the name of Employee: Sneha 726 | Employee ID: 32 727 | Enter Address: Jalgaon 728 | Enter Mobile No.: 9258746315 729 | BASIC PAY [50000 - 60000] : 63524 730 | SORRY!!!!!! BASIC PAY FOR TEAMLEAD MUST BETWEEN [50000 - 60000] 731 | TRY AGAIN..... 732 | BASIC PAY [50000 - 60000] : 56382 733 | ================================================================================= 734 | DOES DO YO HAVE DONE ANY EXTRA WORK 735 | 1. PATENT 736 | 2. OTHER BENIFICIAL WORK 737 | 3.NO 738 | Choice::3 739 | ================================================================================= 740 | =================================================================================================== 741 | ASSISTANT MANAGER MENU ..... 742 | 1. INPUT 743 | 2. DISPLAY 744 | 3. EXIT FROM ASSISTANT MANAGER 745 | Choice::2 746 | =================================================================================================== 747 | **************************************************************** 748 | EMP NAME ID ADDRESS MOBILE 749 | **************************************************************** 750 | Priya 10008 Nanded 8695321479 751 | 752 | **************************************************************** 753 | BASIC PAY : 57421.0 754 | HRA : 5742.1 755 | PF : 6890.5199999999995 756 | GROSS SALARY : 68163.1 757 | NET SALARY : 61215.15900000001 758 | **************************************************************** 759 | **************************************************************** 760 | EMP NAME ID ADDRESS MOBILE 761 | **************************************************************** 762 | Sneha 10009 Jalgaon 9258746315 763 | 764 | **************************************************************** 765 | BASIC PAY : 56382.0 766 | HRA : 5638.200000000001 767 | PF : 6765.84 768 | GROSS SALARY : 62020.2 769 | NET SALARY : 55197.978 770 | **************************************************************** 771 | =================================================================================================== 772 | ASSISTANT MANAGER MENU ..... 773 | 1. INPUT 774 | 2. DISPLAY 775 | 3. EXIT FROM ASSISTANT MANAGER 776 | Choice::3 777 | =================================================================================================== 778 | =================================================================================================== 779 | ================================================================================= 780 | MAIN MENU 781 | 782 | 1.PROGRAMMER 783 | 2.TEAM LEAD 784 | 3.ASSISTANT PROJECT MANAGER 785 | 4.PROJECT MANAGER 786 | 5.EMPLOYEE SEARCH 787 | 6.EXIT 788 | Choice::4 789 | ================================================================================= 790 | PROJECT MANAGER MENU ..... 791 | 1. INPUT 792 | 2. DISPLAY 793 | 3. EXIT FROM PROJECT MANAGER SECTION 794 | Choice::1 795 | =================================================================================================== 796 | Enter the name of Employee: Vivek 797 | Employee ID: 53 798 | Enter Address: Pune 799 | Enter Mobile No.: 8357426935 800 | BASIC PAY [60000 - 70000] : 68532 801 | ================================================================================= 802 | DOES DO YO HAVE DONE ANY EXTRA WORK 803 | 1. PATENT 804 | 2. OTHER BENIFICIAL WORK 805 | 3.NO 806 | Choice::1 807 | DOES DO YO HAVE DONE ANY EXTRA WORK 808 | 1. PATENT 809 | 2. OTHER BENIFICIAL WORK 810 | 3.NO 811 | Choice::2 812 | DOES DO YO HAVE DONE ANY EXTRA WORK 813 | 1. PATENT 814 | 2. OTHER BENIFICIAL WORK 815 | 3.NO 816 | Choice::3 817 | ================================================================================= 818 | =================================================================================================== 819 | PROJECT MANAGER MENU ..... 820 | 1. INPUT 821 | 2. DISPLAY 822 | 3. EXIT FROM PROJECT MANAGER SECTION 823 | Choice::2 824 | =================================================================================================== 825 | **************************************************************** 826 | EMP NAME ID ADDRESS MOBILE 827 | **************************************************************** 828 | Vivek 10009 Pune 8357426935 829 | 830 | **************************************************************** 831 | BASIC PAY : 68532.0 832 | HRA : 6853.200000000001 833 | PF : 8223.84 834 | GROSS SALARY : 80385.2 835 | NET SALARY : 72092.828 836 | **************************************************************** 837 | =================================================================================================== 838 | PROJECT MANAGER MENU ..... 839 | 1. INPUT 840 | 2. DISPLAY 841 | 3. EXIT FROM PROJECT MANAGER SECTION 842 | Choice::3 843 | =================================================================================================== 844 | =================================================================================================== 845 | ================================================================================= 846 | MAIN MENU 847 | 848 | 1.PROGRAMMER 849 | 2.TEAM LEAD 850 | 3.ASSISTANT PROJECT MANAGER 851 | 4.PROJECT MANAGER 852 | 5.EMPLOYEE SEARCH 853 | 6.EXIT 854 | Choice::5 855 | ================================================================================= 856 | ENTER THE DISIGNATION OF EMPLOYEE YOU WANT TO SEARCH : programmer 857 | Enter Emplyee ID:10002 858 | EMPLOYEE FOUND 859 | **************************************************************** 860 | EMP NAME ID ADDRESS MOBILE 861 | **************************************************************** 862 | Vaibhav 10002 Jalgaon 8657575665 863 | 864 | **************************************************************** 865 | BASIC PAY : 35241.0 866 | HRA : 3524.1000000000004 867 | PF : 4228.92 868 | GROSS SALARY : 41765.1 869 | NET SALARY : 37500.939 870 | **************************************************************** 871 | EMPLOYEEE WITH ID 10002 NOT FOUND IN PROGRAMMERS 872 | EMPLOYEEE WITH ID 10002 NOT FOUND IN PROGRAMMERS 873 | =================================================================================================== 874 | ================================================================================= 875 | MAIN MENU 876 | 877 | 1.PROGRAMMER 878 | 2.TEAM LEAD 879 | 3.ASSISTANT PROJECT MANAGER 880 | 4.PROJECT MANAGER 881 | 5.EMPLOYEE SEARCH 882 | 6.EXIT 883 | Choice::5 884 | ================================================================================= 885 | ENTER THE DISIGNATION OF EMPLOYEE YOU WANT TO SEARCH : manager 886 | Enter Emplyee ID:10009 887 | EMPLOYEE FOUND 888 | **************************************************************** 889 | EMP NAME ID ADDRESS MOBILE 890 | **************************************************************** 891 | Vivek 10009 Pune 8357426935 892 | 893 | **************************************************************** 894 | BASIC PAY : 68532.0 895 | HRA : 6853.200000000001 896 | PF : 8223.84 897 | GROSS SALARY : 80385.2 898 | NET SALARY : 72092.828 899 | **************************************************************** 900 | =================================================================================================== 901 | ================================================================================= 902 | MAIN MENU 903 | 904 | 1.PROGRAMMER 905 | 2.TEAM LEAD 906 | 3.ASSISTANT PROJECT MANAGER 907 | 4.PROJECT MANAGER 908 | 5.EMPLOYEE SEARCH 909 | 6.EXIT 910 | Choice::6 911 | ================================================================================= 912 | Would you like to Exit 913 | 1.YES 914 | 2.No 915 | Choice::1 916 | 917 | */ 918 | --------------------------------------------------------------------------------