From 6256b2ed4c89f05a5c23980647d9e517f1a607c5 Mon Sep 17 00:00:00 2001 From: sufyan1111 Date: Wed, 17 Apr 2019 13:27:42 +0200 Subject: [PATCH 1/3] lab1, u15fnscsc003 --- lab1/ABU.class | Bin 0 -> 669 bytes lab1/DisplayTable.class | Bin 0 -> 718 bytes 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 lab1/ABU.class create mode 100644 lab1/DisplayTable.class diff --git a/lab1/ABU.class b/lab1/ABU.class new file mode 100644 index 0000000000000000000000000000000000000000..f8687e30b2821eb44bd9661262df54731db18167 GIT binary patch literal 669 zcmZuvO;6iE6r9bM9b=lWk``K82WXq-P=f?&B@j{@iBkkf1}>a7sTCH*cI7yg`m@?Y zkvQ-J_)&=2B@mFXtv7!2-kaSW`}*ec3cx1X4$62{#%nCvSaR?NZ*45wcxU6i15pVQ^n)x_@o?L$Ak!gd8qbue6eN>$5bi0xq)ovuTEm5d zISVT;R0@kwCW^SqAZbqp}-$I+QaN8o|DFPQ2q zVat+fpH4l18RVYsPbyHI9q*uj9uBf6RPbkjkVa&*Ba{)%Y8Z{D zw1D+XH;w4xLi;%r(Spq{tFIhr8s->XWc?jTq4Shg?1X9|euYDVC;a5of|p6ggPoZmPU%{L$+0(0H^^i`h%|@F}+7Oco1&I33W7d9X<8jTx`E21VCH?AJo)JHmyQcV0TU1;LM5AdUm z_dT09(I)5g-E;4`?dki+>l=V3wzJ4$HiJ3L>sZKQ5lcFjb*$*9=%{K~)v(5pJ`%o& zjv10>?V2HV65QGhlP%%f=R>b!hgZDgQl;1my4=0yp^)den2PSifT7e1JRVx7V$gT_ zgVGMk%HzUkm^N=(J$}zEm-~*@jzZx(hiVlM9XUKgX2`aKVc50Lgxp>D>AWM&42;9j zux?-jn+)ZOyy_Af5_TmtHEbC$Q6pVRe|35{)vcf@NA@Jt_ef9<3RLYt2@MidpMw3b zT0Bws7Xd^5`@1hXJ-ZwIDzzU5k?m3N!H|UVS4bkTE-9giaV1>y{fC{aZYJIV~G yJt0v{J|iW0Ear5~TFg4}_kwv^0py_5iag!3WL_a_6H`By*638GKFXOeftgSIgNXnD literal 0 HcmV?d00001 From 299712af1f26b3ccc6cdf34ad7ca0c7b99d6d82b Mon Sep 17 00:00:00 2001 From: sufyan1111 Date: Thu, 18 Apr 2019 12:40:42 +0100 Subject: [PATCH 2/3] lab1, U15FNSCS003 --- Lab 1/a.java | 12 ++++++++++++ Lab 1/b.java | 28 ++++++++++++++++++++++++++++ Lab 1/c.java | 29 +++++++++++++++++++++++++++++ Lab 1/d.java | 20 ++++++++++++++++++++ Lab 1/e.java | 24 ++++++++++++++++++++++++ Lab 1/f.java | 11 +++++++++++ lab1/ABU.class | Bin 669 -> 0 bytes lab1/DisplayTable.class | Bin 718 -> 0 bytes 8 files changed, 124 insertions(+) create mode 100644 Lab 1/a.java create mode 100644 Lab 1/b.java create mode 100644 Lab 1/c.java create mode 100644 Lab 1/d.java create mode 100644 Lab 1/e.java create mode 100644 Lab 1/f.java delete mode 100644 lab1/ABU.class delete mode 100644 lab1/DisplayTable.class diff --git a/Lab 1/a.java b/Lab 1/a.java new file mode 100644 index 0000000..c5bf002 --- /dev/null +++ b/Lab 1/a.java @@ -0,0 +1,12 @@ +package practicalClass; + +//program to display mathematical table +public class displayTable { + public static void main(String[] args) { + int mulOne=1,mulTwo=2,mulThree=3,mulFour=4; + System.out.println("\t"+mulOne+"\t"+mulTwo+"\t"+mulThree+"\t"+mulFour); + for(int i=1;i<5;i++) { + System.out.println(mulOne*i+"\t"+mulOne*i+"\t"+mulTwo*i+"\t"+mulThree*i+"\t"+mulFour*i); + } + } +} diff --git a/Lab 1/b.java b/Lab 1/b.java new file mode 100644 index 0000000..92cc81b --- /dev/null +++ b/Lab 1/b.java @@ -0,0 +1,28 @@ +package practicalClass; + +import java.util.Scanner; +//program to break file address into file path, file name and its extension +public class labTwo_addressBreak { + public static void main(String[] args) { + Scanner file=new Scanner(System.in); + String path; + boolean check=false; + do { + System.out.println("Please enter File path: "); + path=file.nextLine(); + if (path.contains("\\") && path.contains(".")) { + int index=path.lastIndexOf("\\"); + int ext=path.lastIndexOf("."); + String fileName=path.substring(index+1, ext); + String filePath=path.substring(0, index); + String fileExt=path.substring(ext+1); + System.out.println("\nFor the full name: "+path); + System.out.println("Directory: "+filePath+" \nFile name: "+fileName+" \nExtension: "+fileExt); + check=true; + } + else { + System.out.println("Invalid Path "); + } + }while(!check); + } +} diff --git a/Lab 1/c.java b/Lab 1/c.java new file mode 100644 index 0000000..a2800a5 --- /dev/null +++ b/Lab 1/c.java @@ -0,0 +1,29 @@ +package practicalClass; + +import java.util.Scanner; +//Program to break inputed email into username and domain name +public class labTwo_emailBreak { + public static void main(String[] args) { + Scanner userInput=new Scanner(System.in); + String testString,emailAddress; + boolean check; + do { + System.out.println("Please enter your email e.g: example@mail.com"); + emailAddress=userInput.nextLine(); + //String email_regex="[A-Z]+[a-zA-Z_]+@\b([a-zA-Z]+.) {2}\b?.[a-zA-Z]+"; + String email_regex="^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"+"[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"; + testString=emailAddress; + check=testString.matches(email_regex); + if(!check) { + System.out.println("The email : \""+emailAddress+ "\" is Invalid\n"); + //return; + } + + }while(!check); + + String[] parts= emailAddress.split("@"); + System.out.println("\nFor the email address: "+emailAddress); + System.out.println("The user name is : "+parts[0]+"\nThe domain name is : "+parts[1]); + } +} + diff --git a/Lab 1/d.java b/Lab 1/d.java new file mode 100644 index 0000000..f62b906 --- /dev/null +++ b/Lab 1/d.java @@ -0,0 +1,20 @@ +package practicalClass; + +//program to carry out sin,cos,tan,abs,exp mathematical functions +public class labTwo_mathFunction { + public static void main(String[] args) { + double k; + k=2/4*4%3; + //converting from degrees to radian + double cos=Math.cos(Math.toRadians(30)); + double sin=Math.sin(Math.toRadians(30)); + double tan=Math.tan(Math.toRadians(30)); + //********* output *********** + System.out.println("The value of cos 30: "+cos); + System.out.println("The value of exp(15): "+Math.exp(15)); + System.out.println("The value of sin 30: "+sin); + System.out.println("The absolute value of k is "+Math.abs(k)); + System.out.println("The value of tan 30: "+tan); + } + +} diff --git a/Lab 1/e.java b/Lab 1/e.java new file mode 100644 index 0000000..9e6b824 --- /dev/null +++ b/Lab 1/e.java @@ -0,0 +1,24 @@ +package practicalClass; + +//program to print miles, values of X,Y,Z and also log of a value +public class labTwo_one { + public static void main(String[] args) { + //Lab2 question 1(a) + double miles=10.5; + miles++; + System.out.println("The current value of miles is now: "+miles); + //Lab2 question 1(b) + double X,Y,Z,d=1.0; + int a=1; + X=d+ 43 % 5*(23*3%2); + Y=1.5 *3 +(++a); + Z=3 +(d*d)+4; + System.out.println("\n\nX ="+X+"\nY ="+Y+"\nZ ="+Z); + + //Lab2 question 1(c) + double R,p=3.758; + R=Math.log(p); //R=log(3.758) + System.out.println("\n\nR=log(p) \nR ="+R); + } + +} diff --git a/Lab 1/f.java b/Lab 1/f.java new file mode 100644 index 0000000..c6219d2 --- /dev/null +++ b/Lab 1/f.java @@ -0,0 +1,11 @@ +package practicalClass; + +//program to display a given pattern +public class patternDisplay { + public static void main(String[] args) { + System.out.println("\t*\n\n *\t *\n\n*\t*\t*\n\n*\t\t*"); + System.out.println("\n\n\n*\t*\n\n*\t*\t*\n\n*\t*\n\n*\t*\t*\n\n*\t*"); + System.out.println("\n\n\n*\t\t*\n\n*\t\t*\n\n*\t\t*\n\n*\t\t*\n\n * \t *"); + } + +} diff --git a/lab1/ABU.class b/lab1/ABU.class deleted file mode 100644 index f8687e30b2821eb44bd9661262df54731db18167..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 669 zcmZuvO;6iE6r9bM9b=lWk``K82WXq-P=f?&B@j{@iBkkf1}>a7sTCH*cI7yg`m@?Y zkvQ-J_)&=2B@mFXtv7!2-kaSW`}*ec3cx1X4$62{#%nCvSaR?NZ*45wcxU6i15pVQ^n)x_@o?L$Ak!gd8qbue6eN>$5bi0xq)ovuTEm5d zISVT;R0@kwCW^SqAZbqp}-$I+QaN8o|DFPQ2q zVat+fpH4l18RVYsPbyHI9q*uj9uBf6RPbkjkVa&*Ba{)%Y8Z{D zw1D+XH;w4xLi;%r(Spq{tFIhr8s->XWc?jTq4Shg?1X9|euYDVC;a5of|p6ggPoZmPU%{L$+0(0H^^i`h%|@F}+7Oco1&I33W7d9X<8jTx`E21VCH?AJo)JHmyQcV0TU1;LM5AdUm z_dT09(I)5g-E;4`?dki+>l=V3wzJ4$HiJ3L>sZKQ5lcFjb*$*9=%{K~)v(5pJ`%o& zjv10>?V2HV65QGhlP%%f=R>b!hgZDgQl;1my4=0yp^)den2PSifT7e1JRVx7V$gT_ zgVGMk%HzUkm^N=(J$}zEm-~*@jzZx(hiVlM9XUKgX2`aKVc50Lgxp>D>AWM&42;9j zux?-jn+)ZOyy_Af5_TmtHEbC$Q6pVRe|35{)vcf@NA@Jt_ef9<3RLYt2@MidpMw3b zT0Bws7Xd^5`@1hXJ-ZwIDzzU5k?m3N!H|UVS4bkTE-9giaV1>y{fC{aZYJIV~G yJt0v{J|iW0Ear5~TFg4}_kwv^0py_5iag!3WL_a_6H`By*638GKFXOeftgSIgNXnD From 2879cf82116b66c02fb2202c6f55840885a7bc4e Mon Sep 17 00:00:00 2001 From: sufyan1111 Date: Sat, 4 May 2019 21:21:47 +0100 Subject: [PATCH 3/3] lab3,4,5,6,U15/FNS/CSC/003 --- Lab3/Lab3.java | 64 +++++++++++++++++++++++++++ Lab4/BankAccount.java | 39 +++++++++++++++++ Lab4/BankAccountDemo.java | 37 ++++++++++++++++ Lab4/Box.java | 20 +++++++++ Lab4/BoxDemo.java | 22 ++++++++++ Lab4/Circle.java | 25 +++++++++++ Lab4/CircleDemo.java | 20 +++++++++ Lab4/Rectangle.java | 31 ++++++++++++++ Lab4/RectangleDemo.java | 19 +++++++++ Lab4/Student.java | 76 +++++++++++++++++++++++++++++++++ Lab4/StudentDemo.java | 34 +++++++++++++++ Lab5/ArithmeticProgression.java | 34 +++++++++++++++ Lab5/PseudocodeA.java | 26 +++++++++++ Lab5/PseudocodeB.java | 34 +++++++++++++++ Lab5/PseudocodeC.java | 31 ++++++++++++++ Lab5/QuadraticEquation.java | 39 +++++++++++++++++ Lab5/SwitchCase.java | 37 ++++++++++++++++ Lab6/Author.java | 32 ++++++++++++++ Lab6/BoxDemoModify.java | 28 ++++++++++++ Lab6/BoxModify.java | 43 +++++++++++++++++++ Lab6/Employee1.java | 59 +++++++++++++++++++++++++ Lab6/Employee2.java | 53 +++++++++++++++++++++++ Lab6/Employee3.java | 52 ++++++++++++++++++++++ Lab6/TestAuthor.java | 18 ++++++++ Lab6/TestEmployee1.java | 37 ++++++++++++++++ Lab6/TestEmployee2.java | 35 +++++++++++++++ Lab6/TestEmployee3.java | 36 ++++++++++++++++ 27 files changed, 981 insertions(+) create mode 100644 Lab3/Lab3.java create mode 100644 Lab4/BankAccount.java create mode 100644 Lab4/BankAccountDemo.java create mode 100644 Lab4/Box.java create mode 100644 Lab4/BoxDemo.java create mode 100644 Lab4/Circle.java create mode 100644 Lab4/CircleDemo.java create mode 100644 Lab4/Rectangle.java create mode 100644 Lab4/RectangleDemo.java create mode 100644 Lab4/Student.java create mode 100644 Lab4/StudentDemo.java create mode 100644 Lab5/ArithmeticProgression.java create mode 100644 Lab5/PseudocodeA.java create mode 100644 Lab5/PseudocodeB.java create mode 100644 Lab5/PseudocodeC.java create mode 100644 Lab5/QuadraticEquation.java create mode 100644 Lab5/SwitchCase.java create mode 100644 Lab6/Author.java create mode 100644 Lab6/BoxDemoModify.java create mode 100644 Lab6/BoxModify.java create mode 100644 Lab6/Employee1.java create mode 100644 Lab6/Employee2.java create mode 100644 Lab6/Employee3.java create mode 100644 Lab6/TestAuthor.java create mode 100644 Lab6/TestEmployee1.java create mode 100644 Lab6/TestEmployee2.java create mode 100644 Lab6/TestEmployee3.java diff --git a/Lab3/Lab3.java b/Lab3/Lab3.java new file mode 100644 index 0000000..880bb6b --- /dev/null +++ b/Lab3/Lab3.java @@ -0,0 +1,64 @@ + +/** + * Write a description of class Lab3 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ +import java.util.Scanner; +public class Lab3 +{ + public static void main(String[]arg){ +System.out.println("\nEXERCISES 01 Volume&Surface-area"); +Scanner scann = new Scanner(System.in); +System.out.println("Enter the length:"); +double l = scann.nextDouble(); +System.out.println("Enter the width:"); +double w = scann.nextDouble(); +System.out.println("Enter the heigth:"); +double h = scann.nextDouble(); +double volume = (h*w*l); +double surface = 2*(l*w+l*h+w*h); +System.out.println("The volume of the box: "+volume); +System.out.println("The surface area of the box: "+surface); +System.out.println("\nEXERCISES 02 USERNAME&DOMAIN"); + Scanner scan = new Scanner(System.in); + String domain,username; + System.out.println("Please enter a valid email address"); + String email = scan.nextLine(); + username = email.split("@")[0]; + domain = email.substring(email.indexOf("@")+1); + //username = email.substring(email.indexOf("@")-1); + System.out.println("\nUsername:"+ username); + System.out.println("Domain:"+ domain); + +System.out.println("\nEXERCISES 03 Perimeter&Area"); + Scanner scan1 = new Scanner(System.in); + System.out.println("Enter the 1st sides:"); + int a = scan1.nextInt(); + System.out.println("Enter the 2nd sides:"); + int b = scan1.nextInt(); + System.out.println("Enter the 3rd sides:"); + int c = scan1.nextInt(); + double s =(a+b+c)/2; + double area = Math.sqrt(s*(s-a)*(s-b)*(s-c)); + System.out.println("The Perimeter of triangle is: "+s); + System.out.println("The area of the triangle with the input sides is "+ area+"unit square"); + if(a>b && a>c){ + System.out.println("The longest side is: "+a); + }else if(b>c){ + System.out.println("The longest side is: "+b); + }else{ + System.out.println("The longest side is: "+c); + } + + if(a8) +System.out.println("Execellent to instructor"); +} +} diff --git a/Lab5/QuadraticEquation.java b/Lab5/QuadraticEquation.java new file mode 100644 index 0000000..a1c1f55 --- /dev/null +++ b/Lab5/QuadraticEquation.java @@ -0,0 +1,39 @@ +/** + * Write a description of class QuadraticEquation here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ +import java.util.Scanner; +public class QuadraticEquation +{ + public static void main(String[] args){ + Scanner scan=new Scanner(System.in); + double a,b,c,root1,root2; + int determinant; + System.out.println("Enter value of a: "); + a=scan.nextDouble(); + System.out.println("Enter value of b: "); + b=scan.nextDouble(); + System.out.println("Enter value of c: "); + c=scan.nextDouble(); + root1=(-b+(Math.sqrt(Math.pow(b,2)-(4*a*c))))/(2*a); + root2=(-b-(Math.sqrt(Math.pow(b,2)-(4*a*c))))/(2*a); + determinant= (int)(Math.pow(b,2)-(4*a*c)); + System.out.println("\nThe root of the equation is root1: "+root1+" root2: "+root2); + System.out.println("Determinant: "+determinant); + if(determinant>0) + { + System.out.println("The root are real and distinct: "+root1+" ,"+root2); + } + else if(determinant==0) + { + System.out.println("The root are real and equal: "+root1); + } + else + { + System.out.println("The root are complex"); + } + } + +} diff --git a/Lab5/SwitchCase.java b/Lab5/SwitchCase.java new file mode 100644 index 0000000..00472ba --- /dev/null +++ b/Lab5/SwitchCase.java @@ -0,0 +1,37 @@ +/** + * Write a description of class SwitchCase here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ +import java.util.Scanner; +public class SwitchCase +{ + public static void main(String [] args) + { + int above; + int score ; + char grade; + Scanner input = new Scanner(System.in); + System.out.println("Enter your score"); + score = input.nextInt(); + switch (score){ + case 90: + grade= 'A'; + break; + case 80: + grade= 'B'; + break; + case 70: + grade= 'C'; + break; + case 60: + grade= 'D'; + break; + default: + grade= 'F'; + } + System.out.println("Your test score is "+ score + + ", which is equivalent to the grade " + grade + "."); + } +} diff --git a/Lab6/Author.java b/Lab6/Author.java new file mode 100644 index 0000000..e5d0a45 --- /dev/null +++ b/Lab6/Author.java @@ -0,0 +1,32 @@ + +/** + * Write a description of class Aurthor here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ +public class Author { + private String name; + private String email; + private char gender; + public Author(String name, String email, char gender) { + this.name = name; + this.email = email; + this.gender = gender; + } + public String getName() { + return name; + } + public char getGender() { + return gender; + } + public String getEmail() { + return email; + } + public void setEmail(String email) { + this.email = email; + } + public String toString() { + return name + " (" + gender + ") at " + email; + } +} diff --git a/Lab6/BoxDemoModify.java b/Lab6/BoxDemoModify.java new file mode 100644 index 0000000..00969a1 --- /dev/null +++ b/Lab6/BoxDemoModify.java @@ -0,0 +1,28 @@ + +/** + * Write a description of class BoxDemoModify here. + * + +*@author (MUSA ABUSUFYAN YUSUF) + +* @U15/FNS/CSC/003 + +*/ +public class BoxDemoModify +{ + public static void main(String[] args){ + // Create two Box obj ects + BoxModify box1 = new BoxModify(20.0, 10.0, 15.0); + BoxModify box2 = new BoxModify(box1); + BoxModify box3 = new BoxModify(6.0); + double volume, area; + //double volume, area; + // Get and display volume and surface area of box1 + volume = box1.volume(); + area = box1.surfaceArea(); + System.out.println("Box 1 is " + box1); + System.out.println("Box 2 is "+box2); + System.out.println("Box 3 is "+box3); + // Get and display volume of surface area box2 + System.out.println("\nThe volume of box2 is " + box2.volume() + " cubic cm"); + System.out.println("The surface area of box2 is "+area+" square cm\n") \ No newline at end of file diff --git a/Lab6/BoxModify.java b/Lab6/BoxModify.java new file mode 100644 index 0000000..ecf8a8d --- /dev/null +++ b/Lab6/BoxModify.java @@ -0,0 +1,43 @@ + +/** + * Write a description of class BoxModify here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 */ +public class BoxModify +{ + private double length , width , height; //instance variables + public BoxModify(double boxLength , double boxWidth , double boxHeight) { //constructor + length = boxLength; + width = boxWidth; + height = boxHeight; + } + public BoxModify(BoxModify obj) { //constructor + length = obj.length; + width = obj.width; + height = obj.height; + } + public BoxModify(double boxLength) { //constructor + length = boxLength; + width = boxLength; + height = boxLength; + } + public double volume() { //instant methods + return length * width * height; + } + public double surfaceArea() { + return 2*(length*width + length*height + width*height); + } + public double getLength( ){ + return length; + } + public double getWidth(){ + return width; + } + public double getHeight(){ + return height; + } + public String toString() { + return "\nLength: "+getLength()+" Width: "+getWidth()+" Height:"+getHeight(); + } +} diff --git a/Lab6/Employee1.java b/Lab6/Employee1.java new file mode 100644 index 0000000..5c867e5 --- /dev/null +++ b/Lab6/Employee1.java @@ -0,0 +1,59 @@ + +/** + * Write a description of class Employee1 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ + +public class Employee1 +{ + private int iDNumber; + private String name; + private double salary; + public Employee1(int iD, String employeeName, double employeeSalary){ + iDNumber = iD; + name = employeeName; + salary = employeeSalary; + } + public Employee1(String employeeName, int iD, double employeeSalary){ + iDNumber = iD; + name = employeeName; + salary = employeeSalary; + } + public Employee1(int iD, String employeeName) { + iDNumber = iD; + name = employeeName; + salary = 0.0; + } + public Employee1(String employeeName, int iD) { + iDNumber = iD; + name = employeeName; + salary = 0.0; + } + public void setSalary(double employeeSalary) { + salary = employeeSalary; + } + public int getIDNumber(){ + return iDNumber; + } + public String getName() { + return name; + } + public double getSalary() { + return salary; + } + public void deductions(double telephoneBills) { + salary -= telephoneBills; + } + public void deductions(double telephoneBills, double medicalBills) { + salary -= (telephoneBills + medicalBills); + } + public void raiseSalary(double percentIncrease) { + salary += salary * percentIncrease/100; + } + public void printDetails() { + System.out.println("\nID Number: "+iDNumber+"\nName: "+name+"\nSalary:" + +salary) ; + } +} diff --git a/Lab6/Employee2.java b/Lab6/Employee2.java new file mode 100644 index 0000000..973914f --- /dev/null +++ b/Lab6/Employee2.java @@ -0,0 +1,53 @@ + +/** + * Write a description of class Employee2 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ + +public class Employee2 +{ + private int iDNumber; + private String name; + private double salary; + public Employee2(int iDNumber, String name, double salary) { + this.iDNumber = iDNumber; + this.name = name; + this.salary = salary; + } + public Employee2(String name, int iDNumber, double salary) { + this(iDNumber, name, salary); + } + public Employee2(int iDNumber, String name) { + this(iDNumber, name, 0.0); + } + public Employee2(String name, int iDNumber) { + this(iDNumber, name, 0.0); + } + public void setSalary(double salary) { + this.salary = salary; + } + public int getIDNumber() { + return iDNumber; + } + public String getName() { + return name; + } + public double getSalary() { + return salary; + } + public void deductions(double telephoneBills) { + salary -= telephoneBills; + } + public void deductions(double telephoneBills, double medicalBills) { + salary -= (telephoneBills + medicalBills); + } + public void raiseSalary(double percentIncrease) { + salary += salary * percentIncrease/100; + } + public void printDetails() { + System.out.println("\nID Number: "+iDNumber+"\nName: "+name+"\nSalary:"+salary); + } +} + \ No newline at end of file diff --git a/Lab6/Employee3.java b/Lab6/Employee3.java new file mode 100644 index 0000000..6637863 --- /dev/null +++ b/Lab6/Employee3.java @@ -0,0 +1,52 @@ + +/** + * Write a description of class Employee3 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ + +public class Employee3 +{ + private int iDNumber; + private String name; + private double salary; + public Employee3(int iDNumber, String name, double salary) { + this.iDNumber = iDNumber; + this.name = name; + this.salary = salary; + } + public Employee3(String name, int iDNumber, double salary) { + this(iDNumber, name, salary); + } + public Employee3(int iDNumber, String name) { + this(iDNumber, name, 0.0); + } + public Employee3(String name, int iDNumber) { + this(iDNumber, name, 0.0); + } + public void setSalary(double salary) { + this.salary = salary; + } + public int getIDNumber() { + return iDNumber; + } + public String getName() { + return name; + } + public double getSalary() { + return salary; + } + public void deductions(double telephoneBills) { + salary -= telephoneBills; + } + public void deductions(double telephoneBills, double medicalBills) { + salary -= (telephoneBills + medicalBills); + } + public void raiseSalary(double percentIncrease) { + salary += salary * percentIncrease/100; + } + public String toString() { + return "\nID Number: "+iDNumber+"\nName: "+name+"\nSalary:"+salary; + } +} diff --git a/Lab6/TestAuthor.java b/Lab6/TestAuthor.java new file mode 100644 index 0000000..794cdba --- /dev/null +++ b/Lab6/TestAuthor.java @@ -0,0 +1,18 @@ + +/** + * Write a description of class TestAuthor here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ +public class TestAuthor { + public static void main(String[] args) { + Author auth = new Author("Ndaliman Abdullahi Muhammed", "Phoenixkheeng@gmail.com", 'm'); + System.out.println(auth); + auth.setEmail("7sgeneral@yahoo.com"); + System.out.println(auth); + System.out.println("name is: " + auth.getName()); + System.out.println("gender is: " + auth.getGender()); + System.out.println("email is: " + auth.getEmail()); + } +} \ No newline at end of file diff --git a/Lab6/TestEmployee1.java b/Lab6/TestEmployee1.java new file mode 100644 index 0000000..52e6bc2 --- /dev/null +++ b/Lab6/TestEmployee1.java @@ -0,0 +1,37 @@ + +/** + * Write a description of class TestEmployee1 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ + +import java.util.Scanner; +public class TestEmployee1 +{ + public static void main(String[ ] args) { + Scanner input = new Scanner(System. in); + int number; + String name; + double salary; + System.out.print("Enter Name for Employee 1: "); + name = input.nextLine(); + System.out.print("Enter ID Number for Employee 1: "); + number = input.nextInt(); + System.out.print("Enter Salary for Employee 1: "); + salary = input.nextDouble(); + Employee1 emp1 = new Employee1(number, name, salary); + input.nextLine(); + System.out.print("\nEnter Name for Employee 2: "); + name = input.nextLine(); + System.out.print("Enter ID Number for Employee 2: "); + number = input.nextInt(); + Employee1 emp2 = new Employee1(number, name); + emp2.setSalary(emp1.getSalary()); + emp1.deductions(50); + emp2.deductions(60, 40); + emp1.printDetails(); + emp2.printDetails(); + } +} + diff --git a/Lab6/TestEmployee2.java b/Lab6/TestEmployee2.java new file mode 100644 index 0000000..514d723 --- /dev/null +++ b/Lab6/TestEmployee2.java @@ -0,0 +1,35 @@ + +/** + * Write a description of class TestEmployee2 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ +import java.util.Scanner; +public class TestEmployee2 +{ + public static void main(String[ ] args) { + Scanner input = new Scanner(System. in); + int number; + String name; + double salary; + System.out.print("Enter Name for Employee 1: "); + name = input.nextLine(); + System.out.print("Enter ID Number for Employee 1: "); + number = input.nextInt(); + System.out.print("Enter Salary for Employee 1: "); + salary = input.nextDouble(); + Employee2 emp1 = new Employee2(number, name, salary); + input.nextLine(); + System.out.print("\nEnter Name for Employee 2: "); + name = input.nextLine(); + System.out.print("Enter ID Number for Employee 2: "); + number = input.nextInt(); + Employee2 emp2 = new Employee2(number, name); + emp2.setSalary(emp1.getSalary()); + emp1.deductions(50); + emp2.deductions(60, 40); + emp1.printDetails(); + emp2.printDetails(); + } +} diff --git a/Lab6/TestEmployee3.java b/Lab6/TestEmployee3.java new file mode 100644 index 0000000..4f0d824 --- /dev/null +++ b/Lab6/TestEmployee3.java @@ -0,0 +1,36 @@ + +/** + * Write a description of class TestEmployee3 here. + * + * @author (MUSA ABUSUFYAN YUSUF) + * @U15/FNS/CSC/003 + */ + +import java.util.Scanner; +public class TestEmployee3 +{ + public static void main(String[ ] args) { + Scanner input = new Scanner(System. in); + int number; + String name; + double salary; + System.out.print("Enter Name for Employee 1: "); + name = input.nextLine(); + System.out.print("Enter ID Number for Employee 1: "); + number = input.nextInt(); + System.out.print("Enter Salary for Employee 1: "); + salary = input.nextDouble(); + Employee3 emp1 = new Employee3(number, name, salary); + input.nextLine(); + System.out.print("\nEnter Name for Employee 2: "); + name = input.nextLine(); + System.out.print("Enter ID Number for Employee 2: "); + number = input.nextInt(); + Employee3 emp2 = new Employee3(number, name); + emp2.setSalary(emp1.getSalary()); + emp1.deductions(50); + emp2.deductions(60, 40); + System.out.println(emp1); + System.out.println(emp2); + } +}