From e442347bac5c0db5899366b826552681d9b02d6f Mon Sep 17 00:00:00 2001 From: abdulidris Date: Thu, 25 Apr 2019 07:25:21 -0700 Subject: [PATCH 01/36] lab1,U16/FNS/CSC/2087 --- lab01.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lab01.java 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"); + } + +} From cba35bff82cc6ba934b5fdd392cdf012c7b94fa3 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 19:38:03 +0100 Subject: [PATCH 02/36] Lab3 u16/fns/csc/2087 --- ClosedBox.java | 26 +++++++++++++++++++++++++ EmailAddress.java | 32 +++++++++++++++++++++++++++++++ Triangle.java | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 106 insertions(+) create mode 100644 ClosedBox.java create mode 100644 EmailAddress.java create mode 100644 Triangle.java diff --git a/ClosedBox.java b/ClosedBox.java new file mode 100644 index 0000000..e0d11d9 --- /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:U15/FNS/CSC/061; +//NAME:ALKALI MAMUD; +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..2357b7b --- /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:U15/FNS/CSC/061 +//NAME:ALKALI MAMUD +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/Triangle.java b/Triangle.java new file mode 100644 index 0000000..d674310 --- /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:U15/FNS/CSC/061 +//NAME:ALKALI MAMUD +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); + +} +} From 7c367bdb9196a3d432e0df62fb6dc1cdb978065e Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 19:47:15 +0100 Subject: [PATCH 03/36] Lab4 u16/fns/csc/2087 --- BankAccount.java | 37 ++++++++++++++++++++++++++ BankAccountDemo.java | 51 ++++++++++++++++++++++++++++++++++++ Student.java | 62 ++++++++++++++++++++++++++++++++++++++++++++ StudentDemo.java | 44 +++++++++++++++++++++++++++++++ 4 files changed, 194 insertions(+) create mode 100644 BankAccount.java create mode 100644 BankAccountDemo.java create mode 100644 Student.java create mode 100644 StudentDemo.java diff --git a/BankAccount.java b/BankAccount.java new file mode 100644 index 0000000..a7602a6 --- /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:U15/FNS/CSC/061 +//NAME:ALKALI MAMUD +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..2d66572 --- /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:U15/FNS/CSC/061 +//NAME:ALKALI MAMUD +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/Student.java b/Student.java new file mode 100644 index 0000000..23cc4b2 --- /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:U15/FNS/CSC/061 +//NAME:ALKALI MAMUD +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)); + } + } + + + \ No newline at end of file diff --git a/StudentDemo.java b/StudentDemo.java new file mode 100644 index 0000000..ca2f530 --- /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:U15/FNS/CSC/061 +//NAME:ALKALI MAMUD +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()); + } + +} From e7bbb20f30f7f711e09d9ef109a2247bfbb7cc11 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 19:58:12 +0100 Subject: [PATCH 04/36] Update EmailAddress.java --- EmailAddress.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/EmailAddress.java b/EmailAddress.java index 2357b7b..2292d12 100644 --- a/EmailAddress.java +++ b/EmailAddress.java @@ -3,8 +3,8 @@ * To change this template file, choose Tools | Templates * and open the template in the editor. */ -//MATRIC NUMBER:U15/FNS/CSC/061 -//NAME:ALKALI MAMUD +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris package emailaddress; import java.util.Scanner; public class EmailAddress { From 2e35e6331f24cd2e9575d43512fe25a08aed3068 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 20:00:56 +0100 Subject: [PATCH 05/36] Update BankAccount.java --- BankAccount.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BankAccount.java b/BankAccount.java index a7602a6..493b448 100644 --- a/BankAccount.java +++ b/BankAccount.java @@ -9,8 +9,8 @@ * * @author hp */ -//MATRIC NUMBER:U15/FNS/CSC/061 -//NAME:ALKALI MAMUD +//MATRIC NUMBER:U16/FNS/CSC/2087 +//NAME:Abdullahi idris public class BankAccount { private int accountNumber; private String customerName; From 48d76cb21048e8f3ef4caee0c6b931b5409303f4 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:33:34 +0100 Subject: [PATCH 06/36] Delete BankAccount.java --- BankAccount.java | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 BankAccount.java diff --git a/BankAccount.java b/BankAccount.java deleted file mode 100644 index 493b448..0000000 --- a/BankAccount.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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; - } - - - } - - From 508a25c5ad1f820ec90866f5d503782a9d082470 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:34:43 +0100 Subject: [PATCH 07/36] Delete BankAccountDemo.java --- BankAccountDemo.java | 51 -------------------------------------------- 1 file changed, 51 deletions(-) delete mode 100644 BankAccountDemo.java diff --git a/BankAccountDemo.java b/BankAccountDemo.java deleted file mode 100644 index 2d66572..0000000 --- a/BankAccountDemo.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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:U15/FNS/CSC/061 -//NAME:ALKALI MAMUD -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()); - } -} - - - From 28558a546b350ba38757daea0f5edbaf2a90fccc Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:35:51 +0100 Subject: [PATCH 08/36] Delete ClosedBox.java --- ClosedBox.java | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 ClosedBox.java diff --git a/ClosedBox.java b/ClosedBox.java deleted file mode 100644 index e0d11d9..0000000 --- a/ClosedBox.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * 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/061; -//NAME:ALKALI MAMUD; -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); -} -} From 0ecf0bbbb2e15fc6561b51dba62e9a904dfb1805 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:37:10 +0100 Subject: [PATCH 09/36] Delete EmailAddress.java --- EmailAddress.java | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 EmailAddress.java diff --git a/EmailAddress.java b/EmailAddress.java deleted file mode 100644 index 2292d12..0000000 --- a/EmailAddress.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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]); -} -} - From 1003171ad1442f7f09071fd23460f8f496e20d35 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:38:23 +0100 Subject: [PATCH 10/36] Delete Student.java --- Student.java | 62 ---------------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100644 Student.java diff --git a/Student.java b/Student.java deleted file mode 100644 index 23cc4b2..0000000 --- a/Student.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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:U15/FNS/CSC/061 -//NAME:ALKALI MAMUD -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)); - } - } - - - \ No newline at end of file From b789f9cfb2958bde289415eb83ab4796c054c0ce Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:41:34 +0100 Subject: [PATCH 11/36] Delete StudentDemo.java --- StudentDemo.java | 44 -------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 StudentDemo.java diff --git a/StudentDemo.java b/StudentDemo.java deleted file mode 100644 index ca2f530..0000000 --- a/StudentDemo.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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:U15/FNS/CSC/061 -//NAME:ALKALI MAMUD -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()); - } - -} From ccd5229b4ec68dcff6864047b337f75785955922 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:42:34 +0100 Subject: [PATCH 12/36] Delete Triangle.java --- Triangle.java | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) delete mode 100644 Triangle.java diff --git a/Triangle.java b/Triangle.java deleted file mode 100644 index d674310..0000000 --- a/Triangle.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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/061 -//NAME:ALKALI MAMUD -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); - -} -} From fa0531dffdfda3b81c1c707a4d1d9edb1d44ab2c Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:47:41 +0100 Subject: [PATCH 13/36] Lab3 --- ClosedBox.java | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 ClosedBox.java 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); +} +} From a63663007c55386f4ae0a7387fe1b2d452600f3a Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:49:49 +0100 Subject: [PATCH 14/36] Lab3 u16/fns/csc/2087 --- EmailAddress.java | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 EmailAddress.java 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]); +} +} + From 2a36c49fd28a4c24ce99139878d0b6665236b08a Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:52:16 +0100 Subject: [PATCH 15/36] Lab3 u16/fns/csc/2087 --- Triangle.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Triangle.java 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); + +} +} From 98baca14aff6bfc1b04d742b2716ef10423fbbb8 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:54:28 +0100 Subject: [PATCH 16/36] Lab4 u16/fns/csc/2087 --- BankAccount.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 BankAccount.java 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; + } + + + } + + From c29f52cbfe7aa5077f23326a69b06f23a6aa25eb Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:56:16 +0100 Subject: [PATCH 17/36] Lab4 u16/fns/csc/2087 --- BankAccountDemo.java | 51 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 BankAccountDemo.java 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()); + } +} + + + From c8db968a183f099a78bf60940e2a9526ad139d7c Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 22:57:59 +0100 Subject: [PATCH 18/36] Lab4 u16/fns/csc/2087 --- Student.java | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Student.java 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)); + } + } + + + From 2dc43ea7b6fef83d7c77a448f94bd63c891bddd6 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:00:18 +0100 Subject: [PATCH 19/36] Lab4 u16/fns/csc/2087 From f4de35a5a6ca0b84606cb4b3ee074db21a180e6f Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:03:52 +0100 Subject: [PATCH 20/36] Lab4 u16/fns/csc/2087 --- StudentDemo.java | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 StudentDemo.java 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()); + } + +} From ff6992856c481bdc2cfebf012394ac87cab1a3a5 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:06:05 +0100 Subject: [PATCH 21/36] Lab5 u16/fns/csc/2087 --- ArithmeticProgression.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ArithmeticProgression.java 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); + +} +} From c2abca1b01bfcc35a003f765d13c80801ce4215b Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:07:32 +0100 Subject: [PATCH 22/36] Lab5 u16/fns/csc/2087 --- PseudocodeA.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 PseudocodeA.java 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); +} +} From ee63105606a49887b18411f5cec07336a1e99f1a Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:08:43 +0100 Subject: [PATCH 23/36] Lab5 u16/fns/csc/2087 --- PseudocodeB.java | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 PseudocodeB.java 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!"); +} +} From dda5ec846b54162041edacc3c23c30419e802c12 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:10:17 +0100 Subject: [PATCH 24/36] Lab5 u16/fns/csc/2087 --- PseudocodeC.java | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 PseudocodeC.java 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"); +} +} From 7fa7a44a1433f5b5bc264594884d2b1002fa4b43 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:11:34 +0100 Subject: [PATCH 25/36] Lab5 u16/fns/csc/2087 --- QuadraticEquation.java | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 QuadraticEquation.java 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"); + } + } + +} From 319585a7fd2f047b6f28edd90d0c7649344bdb61 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:12:47 +0100 Subject: [PATCH 26/36] Lab5 u16/fns/csc/2087 --- SwitchCase.java | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 SwitchCase.java 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 + "."); + } +} From db73e8efac6768935979188dd70cc3ac4b620e2e Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:15:07 +0100 Subject: [PATCH 27/36] Lab6 u16/fns/csc/2087 --- Author.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Author.java 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; + } +} From 3f47c64ade13e59c0f64214d6abcfb6ad61d9145 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:16:15 +0100 Subject: [PATCH 28/36] Lab6 u16/fns/csc/2087 --- BoxDemoModify.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 BoxDemoModify.java 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"); + } +} From 8136b9281464fbaf6df5aeb08cc45d20a6c2f5e8 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:17:23 +0100 Subject: [PATCH 29/36] Lab6 u16/fns/csc/2087 --- BoxModify.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 BoxModify.java 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(); + } +} From e508aa19d52166c1a0e42fa276de061577ab04a0 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:18:54 +0100 Subject: [PATCH 30/36] Lab6 u16/fns/csc/2087 --- Employee1.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Employee1.java 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) ; + } +} From dab533c88c667d58a313dd0d96953fd716513482 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:20:47 +0100 Subject: [PATCH 31/36] Lab6 u16/fns/csc/2087 --- Employee2.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 Employee2.java 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); + } +} + From 7ca8b58f0089d73faa8b36145a56f5dbc58beeb7 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:22:11 +0100 Subject: [PATCH 32/36] Lab6 u16/fns/csc/2087 --- Employee3.java | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Employee3.java 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; + } +} From b348c4bdfc2abb38f5598d8d3acf651a7b308223 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:23:59 +0100 Subject: [PATCH 33/36] Lab6 u16/fns/csc/2087 --- TestAuthor.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 TestAuthor.java 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()); + } +} From e4c523f638418c2c97597410d827bec917b5ba20 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:25:48 +0100 Subject: [PATCH 34/36] Lab6 u16/fns/csc/2087 --- TestEmployee1.java | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 TestEmployee1.java 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(); + } +} + From 45985783d989ada4737535e6c9c4fbc6dba91b30 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:27:12 +0100 Subject: [PATCH 35/36] Lab6 u16/fns/csc/2087 --- TestEmployee2.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 TestEmployee2.java 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(); + } +} From 59efb10d67e7fab8f7c4156da0fc6563eca74888 Mon Sep 17 00:00:00 2001 From: Abdulidris <48857318+Abdulidris@users.noreply.github.com> Date: Sun, 5 May 2019 23:28:46 +0100 Subject: [PATCH 36/36] Lab6 u16/fns/csc/2087 --- TestEmployee3.java | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 TestEmployee3.java 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); + } +}