diff --git a/AddressBreak.java b/AddressBreak.java new file mode 100644 index 0000000..d30fb69 --- /dev/null +++ b/AddressBreak.java @@ -0,0 +1,34 @@ + +/** + * Write a description of class AddressBreak here. + * + * @author (your name) + * @version (a version number or a date) + */ +import java.util.Scanner; +public class AddressBreak +{ + //Program that breaks a given full file name into path, filename and extension. + 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/ArithmeticProgression.java b/ArithmeticProgression.java new file mode 100644 index 0000000..3d5c6b4 --- /dev/null +++ b/ArithmeticProgression.java @@ -0,0 +1,32 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +import java.util.Scanner; +public class ArithmeticProgression +{ + public static void main(String [] args){ + int a,d,n; + System.out.println("Assignment1\n"); + Scanner input = new Scanner(System.in); + System.out.println("enter the first term of an arithmetic progression (AP)\n"); + a = input.nextInt(); + + System.out.println("enter the common difference of an arithmetic progression (AP)\n"); + d = input.nextInt(); + + System.out.println("enter the number of terms of an arithmetic progression (AP)\n"); + n = input.nextInt(); + do{ + System.out.println(" invalid input, n cannot be less than 1,Please enter a valid input"); + n = input.nextInt(); + } + while(n<1) ; + double Tn= a+(n-1)*d; + double Sn = (n/2)*(a+Tn); + System.out.println("The nth term of the series is: "+Tn); + System.out.println(" The sum of the first n terms is: "+Sn); + +} +} diff --git a/Author.java b/Author.java new file mode 100644 index 0000000..2797978 --- /dev/null +++ b/Author.java @@ -0,0 +1,30 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +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/BankAccount.java b/BankAccount.java new file mode 100644 index 0000000..a317576 --- /dev/null +++ b/BankAccount.java @@ -0,0 +1,38 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +public class BankAccount +{ + // instance variables - replace the example below with your own + private int accountNumber; + private String customerName; + private double balance; + + /** + * Constructor for objects of class BankAccount + */ + public BankAccount(int acctNumber, String custName, double bal) + { + accountNumber=acctNumber; + customerName=custName; + balance=bal; + } + + //method deposit + public void deposit(double deposit) + { + balance+=deposit; + } + //method withdraw + public double withdraw(double withdraw) + { + balance-=withdraw; + return balance; + } + public double getBalance() + { + return balance; + } +} diff --git a/BankAccountDemo.java b/BankAccountDemo.java new file mode 100644 index 0000000..c628e25 --- /dev/null +++ b/BankAccountDemo.java @@ -0,0 +1,36 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +import java.util.Scanner; +public class BankAccountDemo +{ + public static void main(String[] args){ + Scanner bank= new Scanner(System.in); + int accountNumber; + double balance,withdraw,deposit; + String accountName; + + System.out.print("\nEnter Account Number: "); + accountNumber=bank.nextInt(); + bank.nextLine(); + System.out.print("Enter Customer name: "); + accountName=bank.nextLine(); + System.out.print("Enter initial balance: "); + balance=bank.nextDouble(); + bank.nextLine(); + BankAccount account= new BankAccount(accountNumber,accountName,balance); + // BankAccount account= new BankAccount(accountNumber,accountName,balance); + + + System.out.print("\nEnter amount to deposit: "); + deposit=bank.nextDouble(); + account.deposit(deposit); + System.out.print("New balance is: "+account.getBalance()); + System.out.print("\n\nEnter amount to withdraw: "); + withdraw=bank.nextDouble(); + account.withdraw(withdraw); + System.out.print("New balance is: "+account.getBalance()); + } +} diff --git a/Box.java b/Box.java new file mode 100644 index 0000000..2bd55ca --- /dev/null +++ b/Box.java @@ -0,0 +1,19 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +public class Box { +private double length , width , height; //instance variables +public Box(double boxLength , double boxWidth , double boxHeight) { //constructor +length = boxLength; +width = boxWidth; +height = boxHeight; +} +public double volume() { //instant methods +return length * width * height; +} +public double surfaceArea() { +return 2*(length*width + length*height + width*height); +} +} diff --git a/BoxDemo.java b/BoxDemo.java new file mode 100644 index 0000000..bf014ae --- /dev/null +++ b/BoxDemo.java @@ -0,0 +1,21 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +public class BoxDemo { +public static void main(String[] args) { +// Create two Box objects +Box box1 = new Box(20.0, 10.0, 15.0); +Box box2 = new Box(6.0, 4.0, 2.0); +double volume, area; +// Get and display volume and surface area of box1 +volume = box1.volume(); +area = box1.surfaceArea(); +System.out.println("The volume of box1 is " + volume + " cubic cm"); +System.out.println("The surface area of box1 is "+area+" square cm\n"); +// Get and display volume of surface area box2 +System.out.println("The volume of box2 is " + box2.volume() + " cubic cm"); +System.out.println("The surface area of box2 is "+area+" square cm\n"); +} +} diff --git a/BoxDemoModify.java b/BoxDemoModify.java new file mode 100644 index 0000000..a2a441a --- /dev/null +++ b/BoxDemoModify.java @@ -0,0 +1,26 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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"); + } +} diff --git a/BoxModify.java b/BoxModify.java new file mode 100644 index 0000000..fb0a288 --- /dev/null +++ b/BoxModify.java @@ -0,0 +1,43 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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/Circle.java b/Circle.java new file mode 100644 index 0000000..77f6643 --- /dev/null +++ b/Circle.java @@ -0,0 +1,23 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +public class Circle +{ +private static int numberOfCircles = 0; +private double radius; +public Circle(double circleRadius) { +numberOfCircles++; +radius = circleRadius; +} +public double area() { +return Math.PI * radius * radius; +} +public double circumference() { +return 2.0 * Math.PI * radius; +} +public static int getNumberOfCircles() { +return numberOfCircles; +} +} diff --git a/CircleDemo.java b/CircleDemo.java new file mode 100644 index 0000000..7bfa392 --- /dev/null +++ b/CircleDemo.java @@ -0,0 +1,18 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +public class CircleDemo { +public static void main(String[] args) { +System.out.println("The number of circles is " + Circle.getNumberOfCircles()); +Circle circle1 = new Circle(8.5); +System.out.println("The number of circles is " + Circle.getNumberOfCircles()); +Circle circle2 = new Circle(5.0); +System.out.println("The number of circles is " + Circle.getNumberOfCircles()); +System.out.println("The area of the first circle is \t" + circle1.area() + "square cm"); +System.out.println("The circumference of the first circle is\t" +circle1.circumference() + " cm"); +System.out.println("The area of the second circle is\t" + circle2.area() + "square cm"); +System.out.println("The circumference of the second circle is\t" +circle2.circumference() + " cm\n\n"); + } +} diff --git a/Employee1.java b/Employee1.java new file mode 100644 index 0000000..8264ffc --- /dev/null +++ b/Employee1.java @@ -0,0 +1,57 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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/Employee2.java b/Employee2.java new file mode 100644 index 0000000..460cc9f --- /dev/null +++ b/Employee2.java @@ -0,0 +1,51 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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/Employee3.java b/Employee3.java new file mode 100644 index 0000000..5b9fb3f --- /dev/null +++ b/Employee3.java @@ -0,0 +1,50 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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/Equation.java b/Equation.java new file mode 100644 index 0000000..f199ad0 --- /dev/null +++ b/Equation.java @@ -0,0 +1,20 @@ + +/** + * Write a description of class Equation here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Equation +{ + public static void main (String []args){ + double a,b,c,root1,root2; + a=1; + b=-5; + c=6; + root1=(-b+Math.sqrt(Math.pow(b,2)-4*a*c)/2*a); + System.out.println(root1); + root2=(-b-Math.sqrt(Math.pow(b,2)-4*a*c)/2*a); + System.out.println(root2); + } +} diff --git a/Lab3.java b/Lab3.java new file mode 100644 index 0000000..c73ce47 --- /dev/null +++ b/Lab3.java @@ -0,0 +1,63 @@ + +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +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/QuadraticEquation.java b/QuadraticEquation.java new file mode 100644 index 0000000..d0789bb --- /dev/null +++ b/QuadraticEquation.java @@ -0,0 +1,38 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +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/Rectangle.java b/Rectangle.java new file mode 100644 index 0000000..3e84dc8 --- /dev/null +++ b/Rectangle.java @@ -0,0 +1,29 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +class Rectangle { +private double length , width; +public Rectangle(double rectangleLength , double rectangleWidth) { +length = rectangleLength; +width = rectangleWidth; +} +public double area() { +return length * width; +} +// Accessor methods +public double getLength() { +return length; +} +public double getWidth() { +return width; +} +// Mutator methods +public void setLength(double newLength) { +length = newLength; +} +public void setRectangleWidth(float newWidth) { +width = newWidth; +} +} \ No newline at end of file diff --git a/RectangleDemo.java b/RectangleDemo.java new file mode 100644 index 0000000..a3ad18e --- /dev/null +++ b/RectangleDemo.java @@ -0,0 +1,17 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + public class RectangleDemo { +public static void main(String[] args) { +Rectangle rectangle = new Rectangle(20.0, 10.0); +double area = rectangle.area(); +System.out.println("The area of the rectangle is\t" + area + " square cm"); +System.out.println("The length of the rectangle is\t" + rectangle.getLength() +" cm"); +rectangle.setLength(12.0); +System.out.println("The new length of the rectangle is " +rectangle.getLength() + " cm"); +System.out.println("The new area of the rectangle is " + rectangle.area() + "square cm\n\n"); +} + +} diff --git a/Student.java b/Student.java new file mode 100644 index 0000000..eda96a3 --- /dev/null +++ b/Student.java @@ -0,0 +1,75 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +public class Student +{ + // instance variables + private String name; + private int idNumber; + private double quiz1,quiz2,quiz3; + + /** + * Constructor for objects of class Student + */ + public Student(String name, int id, double quiz1,double quiz2, double quiz3) + { + this.name=name; + this.idNumber=id; + this.quiz1=quiz1; + this.quiz2=quiz2; + this.quiz3=quiz3; + } + + //get name + public String getName(String name) + { + return name; + } + //get id number + public int getId(int id) + { + return id; + } + //get quiz1 + public double getQuizOne(double quiz1) + { + return quiz1; + } + //get quiz2 + public double getQuizTwo(double quiz2) + { + return quiz2; + } + //get quiz3 + public double getQuizThree(double quiz3) + { + return quiz3; + } + //set method for quiz1 + public void setQuizOne(double quiz1){ + this.quiz1=quiz1; + } + //set method for quiz2 + public void setQuizTwo(double quiz2){ + this.quiz2=quiz2; + } + //set method for quiz3 + public void setQuizThree(double quiz3){ + this.quiz3=quiz3; + } + //method to return average of the three quiz + public double getAverage() + { + double average= (getQuizOne(quiz1) + getQuizTwo(quiz2) + getQuizThree(quiz3))/3; + return average; + } + //method to print details of student and scores + public void printDetails() + { + System.out.println("\nStudent Name: "+getName(name)); + System.out.println("Student ID: "+getId(idNumber)); + System.out.println("Quiz Grades: "+getQuizOne(quiz1)+" "+getQuizTwo(quiz2)+" "+getQuizThree(quiz3)); + } +} diff --git a/StudentDemo.java b/StudentDemo.java new file mode 100644 index 0000000..2c4c286 --- /dev/null +++ b/StudentDemo.java @@ -0,0 +1,33 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +import java.util.Scanner; +public class StudentDemo +{ + public static void main(String[] args){ + String name; + int idNumber; + double quiz1,quiz2,quiz3; + Scanner input=new Scanner(System.in); + System.out.print("\n\nEnter Student name: "); + name=input.nextLine(); + System.out.print("Enter Student ID: "); + idNumber=input.nextInt(); + System.out.print("Enter Quiz1 score: "); + quiz1=input.nextDouble(); + System.out.print("Enter Quiz2 score: "); + quiz2=input.nextDouble(); + System.out.print("Enter Quiz3 score: "); + quiz3=input.nextDouble(); + Student stud=new Student(name,idNumber,quiz1,quiz2,quiz3); + stud.printDetails(); + System.out.print("\nAverage: "+stud.getAverage()); + System.out.print("\n\nEnter new score for quiz3: "); + quiz3=input.nextDouble(); + stud.setQuizThree(quiz3); + stud.printDetails(); + System.out.print("\nAverage: "+stud.getAverage()); + } +} diff --git a/SwitchCase.java b/SwitchCase.java new file mode 100644 index 0000000..23e8425 --- /dev/null +++ b/SwitchCase.java @@ -0,0 +1,36 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +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/Table.java b/Table.java new file mode 100644 index 0000000..e1609ce --- /dev/null +++ b/Table.java @@ -0,0 +1,18 @@ + +/** + * Write a description of class Table here. + * + * @author (your name) + * @version (a version number or a date) + */ +public class Table +{ + + public static void main (String args[]){ + System.out.println(" 1 2 3 4\n"); + System.out.println("1 1 2 3 4\n"); + System.out.println("2 2 4 6 16\n"); + System.out.println("3 3 6 9 12\n"); + System.out.println("4 4 8 12 16\n"); + } +} diff --git a/TestAuthor.java b/TestAuthor.java new file mode 100644 index 0000000..72896a8 --- /dev/null +++ b/TestAuthor.java @@ -0,0 +1,16 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +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/TestEmployee1.java b/TestEmployee1.java new file mode 100644 index 0000000..681d54e --- /dev/null +++ b/TestEmployee1.java @@ -0,0 +1,35 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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/TestEmployee2.java b/TestEmployee2.java new file mode 100644 index 0000000..fcff95e --- /dev/null +++ b/TestEmployee2.java @@ -0,0 +1,33 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ +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/TestEmployee3.java b/TestEmployee3.java new file mode 100644 index 0000000..55451ff --- /dev/null +++ b/TestEmployee3.java @@ -0,0 +1,34 @@ +/** + * Write a description of class Lab3 here. + * + * @ jesse john zubakpere u15/fns/csc/082 + */ + +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); + } +}