Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
e442347
lab1,U16/FNS/CSC/2087
Abdulidris Apr 25, 2019
cba35bf
Lab3 u16/fns/csc/2087
Abdulidris May 5, 2019
7c367bd
Lab4 u16/fns/csc/2087
Abdulidris May 5, 2019
e7bbb20
Update EmailAddress.java
Abdulidris May 5, 2019
2e35e63
Update BankAccount.java
Abdulidris May 5, 2019
48d76cb
Delete BankAccount.java
Abdulidris May 5, 2019
508a25c
Delete BankAccountDemo.java
Abdulidris May 5, 2019
28558a5
Delete ClosedBox.java
Abdulidris May 5, 2019
0ecf0bb
Delete EmailAddress.java
Abdulidris May 5, 2019
1003171
Delete Student.java
Abdulidris May 5, 2019
b789f9c
Delete StudentDemo.java
Abdulidris May 5, 2019
ccd5229
Delete Triangle.java
Abdulidris May 5, 2019
fa0531d
Lab3
Abdulidris May 5, 2019
a636630
Lab3 u16/fns/csc/2087
Abdulidris May 5, 2019
2a36c49
Lab3 u16/fns/csc/2087
Abdulidris May 5, 2019
98baca1
Lab4 u16/fns/csc/2087
Abdulidris May 5, 2019
c29f52c
Lab4 u16/fns/csc/2087
Abdulidris May 5, 2019
c8db968
Lab4 u16/fns/csc/2087
Abdulidris May 5, 2019
2dc43ea
Lab4 u16/fns/csc/2087
Abdulidris May 5, 2019
f4de35a
Lab4 u16/fns/csc/2087
Abdulidris May 5, 2019
ff69928
Lab5 u16/fns/csc/2087
Abdulidris May 5, 2019
c2abca1
Lab5 u16/fns/csc/2087
Abdulidris May 5, 2019
ee63105
Lab5 u16/fns/csc/2087
Abdulidris May 5, 2019
dda5ec8
Lab5 u16/fns/csc/2087
Abdulidris May 5, 2019
7fa7a44
Lab5 u16/fns/csc/2087
Abdulidris May 5, 2019
319585a
Lab5 u16/fns/csc/2087
Abdulidris May 5, 2019
db73e8e
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
3f47c64
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
8136b92
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
e508aa1
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
dab533c
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
7ca8b58
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
b348c4b
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
e4c523f
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
4598578
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
59efb10
Lab6 u16/fns/csc/2087
Abdulidris May 5, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions ArithmeticProgression.java
Original file line number Diff line number Diff line change
@@ -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);

}
}
34 changes: 34 additions & 0 deletions Author.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
37 changes: 37 additions & 0 deletions BankAccount.java
Original file line number Diff line number Diff line change
@@ -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;
}


}


51 changes: 51 additions & 0 deletions BankAccountDemo.java
Original file line number Diff line number Diff line change
@@ -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());
}
}



29 changes: 29 additions & 0 deletions BoxDemoModify.java
Original file line number Diff line number Diff line change
@@ -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");
}
}
46 changes: 46 additions & 0 deletions BoxModify.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
26 changes: 26 additions & 0 deletions ClosedBox.java
Original file line number Diff line number Diff line change
@@ -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);
}
}
32 changes: 32 additions & 0 deletions EmailAddress.java
Original file line number Diff line number Diff line change
@@ -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]);
}
}

60 changes: 60 additions & 0 deletions Employee1.java
Original file line number Diff line number Diff line change
@@ -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) ;
}
}
Loading