diff --git a/ArithmeticProgression.java b/ArithmeticProgression.java new file mode 100644 index 0000000..a9c5f06 --- /dev/null +++ b/ArithmeticProgression.java @@ -0,0 +1,36 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:ABDULLAHI IDRIS; +package ArithmeticProgression; + +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..792ec3d --- /dev/null +++ b/Author.java @@ -0,0 +1,34 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U15/FNS/CSC/2087; +//NAME:Abdullahi idris; +package TestAuthor; + +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..f704fce --- /dev/null +++ b/BankAccount.java @@ -0,0 +1,37 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package bankaccount; + +/** + * + * @author hp + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris +public class BankAccount { +private int accountNumber; +private String customerName; +private double balance; + public BankAccount (int acctNumber, String custName, double bal){ + accountNumber=acctNumber; + customerName=custName; + balance=bal; + } + public void deposit(double deposit){ + balance+=deposit; + } + 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..a35b9da --- /dev/null +++ b/BankAccountDemo.java @@ -0,0 +1,51 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package bankaccountdemo; + +/** + * + * @author hp + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris +import java.util.Scanner; +public class BankAccountDemo { + + /** + * @param args the command line arguments + */ + 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/BoxDemoModify.java b/BoxDemoModify.java new file mode 100644 index 0000000..5558140 --- /dev/null +++ b/BoxDemoModify.java @@ -0,0 +1,29 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package BoxDemoModify; + +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..6563aa7 --- /dev/null +++ b/BoxModify.java @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package BoxModify; + +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/ClosedBox.java b/ClosedBox.java new file mode 100644 index 0000000..4d28f2a --- /dev/null +++ b/ClosedBox.java @@ -0,0 +1,26 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package ClosedBox; + +import java.util.Scanner; +import java.io.IOException; +public class ClosedBox { +public static void main(String[] args) { + Scanner input= new Scanner(System.in); + System.out.print("Enter the length:"); + double length = input.nextDouble(); + System.out.print("Enter the width:"); + double width = input.nextDouble(); + System.out.print("Enter the height:"); + double height = input.nextDouble(); + double volume = length * width * height; + System.out.println("The volume of the box is:"+volume); + double surfacearea = 2*(height*width)+2*(height*length)+2*(width*length); + System.out.println("The surface area of the box is:"+surfacearea); +} +} diff --git a/EmailAddress.java b/EmailAddress.java new file mode 100644 index 0000000..5b546e3 --- /dev/null +++ b/EmailAddress.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris +package emailaddress; +import java.util.Scanner; +public class EmailAddress { +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/Employee1.java b/Employee1.java new file mode 100644 index 0000000..22e79fd --- /dev/null +++ b/Employee1.java @@ -0,0 +1,60 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris; +package Employee1; + +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..6f6bfc9 --- /dev/null +++ b/Employee2.java @@ -0,0 +1,54 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package Employee2; + +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); + } +} + diff --git a/Employee3.java b/Employee3.java new file mode 100644 index 0000000..1970158 --- /dev/null +++ b/Employee3.java @@ -0,0 +1,53 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package Employee3; + +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/PseudocodeA.java b/PseudocodeA.java new file mode 100644 index 0000000..f115f64 --- /dev/null +++ b/PseudocodeA.java @@ -0,0 +1,28 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package PsedocodeA; + +import java.util.Scanner; +public class PseudocodeA +{ + public static void main(String[]arg){ + int grade; + double average; + int total=0; + int counter=1; + Scanner input = new Scanner(System.in); + while(counter<=10){ + System.out.println("Enter enter next grade"); + grade=input.nextInt(); + total=total+grade; + counter=counter+1; +} + average = total/10; + System.out.println("The class avarage: "+average); +} +} diff --git a/PseudocodeB.java b/PseudocodeB.java new file mode 100644 index 0000000..5853d0a --- /dev/null +++ b/PseudocodeB.java @@ -0,0 +1,36 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package PseudocodeB; + +import java.util.Scanner; +public class PseudocodeB +{ + public static void main(String[]arg){ + int total = 0; + int counter = 0; + int grade; + float average; + Scanner input = new Scanner(System.in); + System.out.println("Enter the first grade,type 00 to indicate the end"); + grade=input.nextInt(); + while(grade!=00){ + total=total+grade; + counter=counter+1; + System.out.println("Enter the next grade,type 00 to indicate the end"); + grade=input.nextInt(); + if(grade==0){ + break; + } +} +if(counter!=0){ + average=total/counter; + System.out.println("The avarage: "+average); +}else +System.out.println("No grades were entered!"); +} +} diff --git a/PseudocodeC.java b/PseudocodeC.java new file mode 100644 index 0000000..cc0bffb --- /dev/null +++ b/PseudocodeC.java @@ -0,0 +1,33 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package PseudocodeC; + +import java.util.Scanner; +public class PseudocodeC +{ +public static void main(String[]arg){ +int passes=0; +int failure=0; +int student=1; +int result; +Scanner input = new Scanner(System.in); +while(student<=10){ +System.out.println("Enter result,1=pass,0=fail:"); +result=input.nextInt(); +if(result==1) +passes=passes+1; +else +failure=failure+1; +student=student+1; +} +System.out.println("Passed: "+passes); +System.out.println("Failed: "+failure); +if(passes>8) +System.out.println("Execellent to instructor"); +} +} diff --git a/QuadraticEquation.java b/QuadraticEquation.java new file mode 100644 index 0000000..44a35d9 --- /dev/null +++ b/QuadraticEquation.java @@ -0,0 +1,42 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package QuadraticEquation; + +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/Student.java b/Student.java new file mode 100644 index 0000000..86386b6 --- /dev/null +++ b/Student.java @@ -0,0 +1,62 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package studentdemo; + +/** + * + * @author hp + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris +public class Student{ + private String name; + private int idNumber; + private double quiz1,quiz2,quiz3; + 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; +} + public String getName(String name){ + return name; + } + public int getId(int id){ + return id; + } + public double getQuizOne(double quiz1){ + return quiz1; + } + public double getQuizTwo(double quiz2){ + return quiz2; + } + public double getQuizThree(double quiz3){ + return quiz3; + } + public void setQuizOne(double quiz1 ){ + this.quiz1=quiz1; + } + public void setQuizTwo(double quiz2 ){ + this.quiz2=quiz2; + } + public void setQuizThree(double quiz3 ){ + this.quiz3=quiz3; + } + public double getAverage(){ + double average= (getQuizOne (quiz1) + getQuizTwo (quiz2)+ getQuizThree (quiz3))/3; + return average; + } + public void printDetails() + { + System.out.println("Student 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..127a1a1 --- /dev/null +++ b/StudentDemo.java @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package studentdemo; + +/** + * + * @author hp + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris +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.println("Enter Student name:"); + name=input.nextLine(); + System.out.println("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 study =new Student(name,idNumber,quiz1,quiz2,quiz3); + study.printDetails(); + System.out.println("Average: "+study.getAverage()); + + System.out.println("Enter new score for quiz3: "); + quiz3=input.nextDouble(); + study.setQuizThree(quiz3); + + study.printDetails(); + System.out.println("Average: "+study.getAverage()); + } + +} diff --git a/SwitchCase.java b/SwitchCase.java new file mode 100644 index 0000000..24383f3 --- /dev/null +++ b/SwitchCase.java @@ -0,0 +1,40 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package SwitchCase; + +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/TestAuthor.java b/TestAuthor.java new file mode 100644 index 0000000..3dfbee3 --- /dev/null +++ b/TestAuthor.java @@ -0,0 +1,20 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris; +package TestAuthor; + +public class TestAuthor { + public static void main(String[] args) { + Author auth = new Author("Alkali Mamud "Mamudalkakli@yahoo.com", 'm'); + System.out.println(auth); + auth.setEmail("mamudalkali@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()); + } +} diff --git a/TestEmployee1.java b/TestEmployee1.java new file mode 100644 index 0000000..4c06e6b --- /dev/null +++ b/TestEmployee1.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U15/FNS/CSC/2087; +//NAME:Abdullahi idris; +package TestEmployee1; + +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..36780f9 --- /dev/null +++ b/TestEmployee2.java @@ -0,0 +1,37 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package TestEmployee2; + +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..38dea2c --- /dev/null +++ b/TestEmployee3.java @@ -0,0 +1,37 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087; +//NAME:Abdullahi idris; +package TestEmployee3; + +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); + } +} diff --git a/Triangle.java b/Triangle.java new file mode 100644 index 0000000..08f1e50 --- /dev/null +++ b/Triangle.java @@ -0,0 +1,48 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris +package triangle; +import java.util.Scanner; +public class Triangle { +public static void main(String[] args) { +Scanner Input=new Scanner(System.in);double a,b,c,p,s,longest,smallest,remainder,area; +System.out.print("Enter the value of side a "); +a=Input.nextDouble(); +System.out.print("Enter the value of side b "); +b=Input.nextDouble(); +System.out.print("Enter the value of side c "); +c=Input.nextDouble(); +p=a+b+c; +s=(a+b+c)/2; +area=Math.sqrt(s*(p-a)*(s-b)*(s-c)); +if( a >= b && a >= c){ +longest=a; +} +else if (b >= a && b >= c){ +longest=b; +} +else{ +longest=c; +} +if( a <= b && a <= c){ +smallest=a; +} +else if (b <= a && b <= c){ +smallest=b; +} +else{ +smallest=c; +} +remainder=longest%smallest; +System.out.println("The perimeter of triangle is "+p); +System.out.println("The area of triangle with sides a= "+a+" b= "+b+" c= "+c+" is "+String.format("%.2f",area)+"units"); +System.out.println("The longest side is: "+longest); +System.out.println("The smallest side is: "+smallest); +System.out.println("The remainder is: "+remainder); + +} +} diff --git a/lab01.java b/lab01.java new file mode 100644 index 0000000..0968dae --- /dev/null +++ b/lab01.java @@ -0,0 +1,14 @@ +package practicalClass; + +//program to display a given pattern +//U15/FNS/CSC/2087 +public class patternDisplay { + public static void main(String[] args) { + System.out.println("\n*\t*\n*\t*\n*\t*\n*\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*\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 *"); + System.out.println("my name is Abdullahi Idris matric number:U16/FNS/CSC/2087"); + } + +}