Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
34 changes: 34 additions & 0 deletions AddressBreak.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

/**
* Write a description of class AddressBreak here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class AddressBreak
{
//Program that breaks a given full file name into path, filename and extension.
public static void main(String[] args) {
Scanner file=new Scanner(System.in);
String path;
boolean check=false;
do {
System.out.println("Please enter File path: ");
path=file.nextLine();
if (path.contains("\\") && path.contains(".")) {
int index=path.lastIndexOf("\\");
int ext=path.lastIndexOf(".");
String fileName=path.substring(index+1, ext);
String filePath=path.substring(0, index);
String fileExt=path.substring(ext+1);
System.out.println("\nFor the full name: "+path);
System.out.println("Directory: "+filePath+" \nFile name: "+fileName+" \nExtension: "+fileExt);
check=true;
}
else {
System.out.println("Invalid Path ");
}
}while(!check);
}
}
32 changes: 32 additions & 0 deletions ArithmeticProgression.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
import java.util.Scanner;
public class ArithmeticProgression
{
public static void main(String [] args){
int a,d,n;
System.out.println("Assignment1\n");
Scanner input = new Scanner(System.in);
System.out.println("enter the first term of an arithmetic progression (AP)\n");
a = input.nextInt();

System.out.println("enter the common difference of an arithmetic progression (AP)\n");
d = input.nextInt();

System.out.println("enter the number of terms of an arithmetic progression (AP)\n");
n = input.nextInt();
do{
System.out.println(" invalid input, n cannot be less than 1,Please enter a valid input");
n = input.nextInt();
}
while(n<1) ;
double Tn= a+(n-1)*d;
double Sn = (n/2)*(a+Tn);
System.out.println("The nth term of the series is: "+Tn);
System.out.println(" The sum of the first n terms is: "+Sn);

}
}
30 changes: 30 additions & 0 deletions Author.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
public class Author {
private String name;
private String email;
private char gender;
public Author(String name, String email, char gender) {
this.name = name;
this.email = email;
this.gender = gender;
}
public String getName() {
return name;
}
public char getGender() {
return gender;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String toString() {
return name + " (" + gender + ") at " + email;
}
}
38 changes: 38 additions & 0 deletions BankAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
public class BankAccount
{
// instance variables - replace the example below with your own
private int accountNumber;
private String customerName;
private double balance;

/**
* Constructor for objects of class BankAccount
*/
public BankAccount(int acctNumber, String custName, double bal)
{
accountNumber=acctNumber;
customerName=custName;
balance=bal;
}

//method deposit
public void deposit(double deposit)
{
balance+=deposit;
}
//method withdraw
public double withdraw(double withdraw)
{
balance-=withdraw;
return balance;
}
public double getBalance()
{
return balance;
}
}
36 changes: 36 additions & 0 deletions BankAccountDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
import java.util.Scanner;
public class BankAccountDemo
{
public static void main(String[] args){
Scanner bank= new Scanner(System.in);
int accountNumber;
double balance,withdraw,deposit;
String accountName;

System.out.print("\nEnter Account Number: ");
accountNumber=bank.nextInt();
bank.nextLine();
System.out.print("Enter Customer name: ");
accountName=bank.nextLine();
System.out.print("Enter initial balance: ");
balance=bank.nextDouble();
bank.nextLine();
BankAccount account= new BankAccount(accountNumber,accountName,balance);
// BankAccount account= new BankAccount(accountNumber,accountName,balance);


System.out.print("\nEnter amount to deposit: ");
deposit=bank.nextDouble();
account.deposit(deposit);
System.out.print("New balance is: "+account.getBalance());
System.out.print("\n\nEnter amount to withdraw: ");
withdraw=bank.nextDouble();
account.withdraw(withdraw);
System.out.print("New balance is: "+account.getBalance());
}
}
19 changes: 19 additions & 0 deletions Box.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
public class Box {
private double length , width , height; //instance variables
public Box(double boxLength , double boxWidth , double boxHeight) { //constructor
length = boxLength;
width = boxWidth;
height = boxHeight;
}
public double volume() { //instant methods
return length * width * height;
}
public double surfaceArea() {
return 2*(length*width + length*height + width*height);
}
}
21 changes: 21 additions & 0 deletions BoxDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
public class BoxDemo {
public static void main(String[] args) {
// Create two Box objects
Box box1 = new Box(20.0, 10.0, 15.0);
Box box2 = new Box(6.0, 4.0, 2.0);
double volume, area;
// Get and display volume and surface area of box1
volume = box1.volume();
area = box1.surfaceArea();
System.out.println("The volume of box1 is " + volume + " cubic cm");
System.out.println("The surface area of box1 is "+area+" square cm\n");
// Get and display volume of surface area box2
System.out.println("The volume of box2 is " + box2.volume() + " cubic cm");
System.out.println("The surface area of box2 is "+area+" square cm\n");
}
}
26 changes: 26 additions & 0 deletions BoxDemoModify.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/

public class BoxDemoModify
{
public static void main(String[] args){
// Create two Box obj ects
BoxModify box1 = new BoxModify(20.0, 10.0, 15.0);
BoxModify box2 = new BoxModify(box1);
BoxModify box3 = new BoxModify(6.0);
double volume, area;
//double volume, area;
// Get and display volume and surface area of box1
volume = box1.volume();
area = box1.surfaceArea();
System.out.println("Box 1 is " + box1);
System.out.println("Box 2 is "+box2);
System.out.println("Box 3 is "+box3);
// Get and display volume of surface area box2
System.out.println("\nThe volume of box2 is " + box2.volume() + " cubic cm");
System.out.println("The surface area of box2 is "+area+" square cm\n");
}
}
43 changes: 43 additions & 0 deletions BoxModify.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/

public class BoxModify
{
private double length , width , height; //instance variables
public BoxModify(double boxLength , double boxWidth , double boxHeight) { //constructor
length = boxLength;
width = boxWidth;
height = boxHeight;
}
public BoxModify(BoxModify obj) { //constructor
length = obj.length;
width = obj.width;
height = obj.height;
}
public BoxModify(double boxLength) { //constructor
length = boxLength;
width = boxLength;
height = boxLength;
}
public double volume() { //instant methods
return length * width * height;
}
public double surfaceArea() {
return 2*(length*width + length*height + width*height);
}
public double getLength( ){
return length;
}
public double getWidth(){
return width;
}
public double getHeight(){
return height;
}
public String toString() {
return "\nLength: "+getLength()+" Width: "+getWidth()+" Height:"+getHeight();
}
}
23 changes: 23 additions & 0 deletions Circle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
public class Circle
{
private static int numberOfCircles = 0;
private double radius;
public Circle(double circleRadius) {
numberOfCircles++;
radius = circleRadius;
}
public double area() {
return Math.PI * radius * radius;
}
public double circumference() {
return 2.0 * Math.PI * radius;
}
public static int getNumberOfCircles() {
return numberOfCircles;
}
}
18 changes: 18 additions & 0 deletions CircleDemo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/
public class CircleDemo {
public static void main(String[] args) {
System.out.println("The number of circles is " + Circle.getNumberOfCircles());
Circle circle1 = new Circle(8.5);
System.out.println("The number of circles is " + Circle.getNumberOfCircles());
Circle circle2 = new Circle(5.0);
System.out.println("The number of circles is " + Circle.getNumberOfCircles());
System.out.println("The area of the first circle is \t" + circle1.area() + "square cm");
System.out.println("The circumference of the first circle is\t" +circle1.circumference() + " cm");
System.out.println("The area of the second circle is\t" + circle2.area() + "square cm");
System.out.println("The circumference of the second circle is\t" +circle2.circumference() + " cm\n\n");
}
}
57 changes: 57 additions & 0 deletions Employee1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Write a description of class Lab3 here.
*
* @ jesse john zubakpere u15/fns/csc/082
*/

public class Employee1
{
private int iDNumber;
private String name;
private double salary;
public Employee1(int iD, String employeeName, double employeeSalary){
iDNumber = iD;
name = employeeName;
salary = employeeSalary;
}
public Employee1(String employeeName, int iD, double employeeSalary){
iDNumber = iD;
name = employeeName;
salary = employeeSalary;
}
public Employee1(int iD, String employeeName) {
iDNumber = iD;
name = employeeName;
salary = 0.0;
}
public Employee1(String employeeName, int iD) {
iDNumber = iD;
name = employeeName;
salary = 0.0;
}
public void setSalary(double employeeSalary) {
salary = employeeSalary;
}
public int getIDNumber(){
return iDNumber;
}
public String getName() {
return name;
}
public double getSalary() {
return salary;
}
public void deductions(double telephoneBills) {
salary -= telephoneBills;
}
public void deductions(double telephoneBills, double medicalBills) {
salary -= (telephoneBills + medicalBills);
}
public void raiseSalary(double percentIncrease) {
salary += salary * percentIncrease/100;
}
public void printDetails() {
System.out.println("\nID Number: "+iDNumber+"\nName: "+name+"\nSalary:"
+salary) ;
}
}
Loading