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
Binary file added Lab 3/Box.class
Binary file not shown.
7 changes: 7 additions & 0 deletions Lab 3/Box.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#BlueJ class context
comment0.target=Box
comment1.params=
comment1.target=double\ getVolume()
comment2.params=
comment2.target=double\ getSurfaceArea()
numComments=3
21 changes: 21 additions & 0 deletions Lab 3/Box.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

public class Box
{
double length;
double width;
double height;
double volume;
double surfaceArea;

public double getVolume()
{
volume = length * width * height;
return volume;
}

public double getSurfaceArea()
{
surfaceArea = length + width + height;
return volume;
}
}
Binary file added Lab 3/QuestionOne.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Lab 3/QuestionOne.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.target=QuestionOne
comment1.params=args
comment1.target=void\ main(java.lang.String[])
numComments=2
23 changes: 23 additions & 0 deletions Lab 3/QuestionOne.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import java.util.Scanner;
public class QuestionOne
{

public static void main(String[] args)
{
Box box = new Box();

Scanner input = new Scanner(System.in);

System.out.println("Enter the Length");
box.length = input.nextDouble();

System.out.println("Enter the Width");
box.width = input.nextDouble();

System.out.println("Enter the Length");
box.height = input.nextDouble();

System.out.println("The volume is: " + box.getVolume());
System.out.println("The volume is: " + box.getSurfaceArea());
}
}
Binary file added Lab 3/QuestionThree.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Lab 3/QuestionThree.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.target=QuestionThree
comment1.params=args
comment1.target=void\ main(java.lang.String[])
numComments=2
25 changes: 25 additions & 0 deletions Lab 3/QuestionThree.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

import java.util.Scanner;
public class QuestionThree
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please enter the sides of the Triangle\n First Side: ");
int firstSide = input.nextInt();

System.out.println("Second Side: ");
int secondSide = input.nextInt();

System.out.println("Third Side: ");
int thirdSide = input.nextInt();

Triangle triangle = new Triangle(firstSide, secondSide, thirdSide);

System.out.println("The Perimter of the Triangle is: " + triangle.getPerimeter());
System.out.println("The Area of the Triangle is: " + triangle.getArea());
System.out.println("The Longest side of the Triangle is: " + triangle.hypotenus);
System.out.println("The Shortest side of the Triangle is: " + triangle.shortestSide);
System.out.println("The remainder is: " + triangle.getRatio());
}
}
Binary file added Lab 3/QuestionTwo.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Lab 3/QuestionTwo.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.target=QuestionTwo
comment1.params=args
comment1.target=void\ main(java.lang.String[])
numComments=2
14 changes: 14 additions & 0 deletions Lab 3/QuestionTwo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.util.Scanner;
public class QuestionTwo
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please enter your e-mail address ");
String email = input.nextLine();
User user = new User();
user.readEmail(email);
System.out.println("User Name is: " + user.userName);
System.out.println("Domain Name is: " + user.domainName);
}
}
12 changes: 12 additions & 0 deletions Lab 3/README.TXT
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
------------------------------------------------------------------------
This is the project README file. Here, you should describe your project.
Tell the reader (someone who does not know anything about this project)
all he/she needs to know. The comments should usually include at least:
------------------------------------------------------------------------

PROJECT TITLE: Java 2019
PURPOSE OF PROJECT: Practical Class
VERSION or DATE: Lab 3
HOW TO START THIS PROJECT:
AUTHORS: U15/FNS/CSC/054
USER INSTRUCTIONS:
Binary file added Lab 3/Triangle.class
Binary file not shown.
11 changes: 11 additions & 0 deletions Lab 3/Triangle.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=Triangle
comment1.params=s1\ s2\ s3
comment1.target=Triangle(int,\ int,\ int)
comment2.params=
comment2.target=double\ getPerimeter()
comment3.params=
comment3.target=double\ getArea()
comment4.params=
comment4.target=double\ getRatio()
numComments=5
62 changes: 62 additions & 0 deletions Lab 3/Triangle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@

public class Triangle
{
int hypotenus;
int shortestSide;
int a;
int b;
int c;

public Triangle(int s1, int s2, int s3)
{
a = s1;
b = s2;
c = s3;

if (a > b && a > c)
{
hypotenus = a;
if (b > c)
shortestSide = c;
else if (c > b)
shortestSide = b;
}

else if (b > a && b > c)
{
hypotenus = b;
if (a > c)
shortestSide = c;
else if (c > a)
shortestSide = a;
}
else if (c > a && c > b)
{
hypotenus = c;
if (a > b)
shortestSide = b;
else if (b > a)
shortestSide = a;
}
}


public double getPerimeter()
{
double perimeter = a + b + c;
return perimeter;
}

public double getArea()
{
//using Heron's Formula
double s = (a + b + c)/2;
double area = Math.sqrt(s *((s-a) * (s-b) * (s-c)));
return area;
}

public double getRatio()
{
return hypotenus/shortestSide;
}
}
Binary file added Lab 3/User.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Lab 3/User.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.target=User
comment1.params=userEmail
comment1.target=void\ readEmail(java.lang.String)
numComments=2
16 changes: 16 additions & 0 deletions Lab 3/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

public class User
{
String email;
String domainName;
String userName;

public void readEmail(String userEmail)
{
email = userEmail;
int emailNo = email.indexOf("@");
domainName = email.substring(emailNo + 1);
userName = email.substring(0,emailNo);
}

}
76 changes: 76 additions & 0 deletions Lab 3/package.bluej
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#BlueJ package file
dependency1.from=QuestionOne
dependency1.to=Box
dependency1.type=UsesDependency
dependency2.from=QuestionTwo
dependency2.to=User
dependency2.type=UsesDependency
dependency3.from=QuestionThree
dependency3.to=Triangle
dependency3.type=UsesDependency
editor.fx.0.height=739
editor.fx.0.width=816
editor.fx.0.x=275
editor.fx.0.y=-4
objectbench.height=98
objectbench.width=657
package.divider.horizontal=0.6
package.divider.vertical=0.8346456692913385
package.editor.height=523
package.editor.width=567
package.editor.x=100
package.editor.y=100
package.frame.height=735
package.frame.width=697
package.numDependencies=3
package.numTargets=6
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.height=58
readme.name=@README
readme.width=47
readme.x=10
readme.y=10
target1.height=50
target1.name=QuestionOne
target1.showInterface=false
target1.type=ClassTarget
target1.width=110
target1.x=70
target1.y=10
target2.height=50
target2.name=User
target2.showInterface=false
target2.type=ClassTarget
target2.width=80
target2.x=230
target2.y=90
target3.height=50
target3.name=QuestionTwo
target3.showInterface=false
target3.type=ClassTarget
target3.width=110
target3.x=70
target3.y=100
target4.height=50
target4.name=Triangle
target4.showInterface=false
target4.type=ClassTarget
target4.width=80
target4.x=230
target4.y=180
target5.height=50
target5.name=Box
target5.showInterface=false
target5.type=ClassTarget
target5.width=80
target5.x=230
target5.y=10
target6.height=50
target6.name=QuestionThree
target6.showInterface=false
target6.type=ClassTarget
target6.width=120
target6.x=70
target6.y=180
Binary file added Lab 4/BankAccount.class
Binary file not shown.
11 changes: 11 additions & 0 deletions Lab 4/BankAccount.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#BlueJ class context
comment0.target=BankAccount
comment1.params=number\ name\ balance
comment1.target=BankAccount(java.lang.String,\ java.lang.String,\ int)
comment2.params=amountToDeposit
comment2.target=void\ deposit(int)
comment3.params=amountToWithdraw
comment3.target=void\ withdraw(int)
comment4.params=
comment4.target=int\ getBalance()
numComments=5
30 changes: 30 additions & 0 deletions Lab 4/BankAccount.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

public class BankAccount
{
private String accountNumber;
private String accountName;
private int accountBalance;

public BankAccount(String number, String name, int balance)
{
accountNumber = number;
accountName = name;
accountBalance = balance;
}

public void deposit(int amountToDeposit)
{

accountBalance = accountBalance + amountToDeposit;
}

public void withdraw(int amountToWithdraw)
{
accountBalance = accountBalance - amountToWithdraw;
}

public int getBalance()
{
return accountBalance;
}
}
Binary file added Lab 4/Box.class
Binary file not shown.
9 changes: 9 additions & 0 deletions Lab 4/Box.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#BlueJ class context
comment0.target=Box
comment1.params=boxLength\ boxWidth\ boxHeight
comment1.target=Box(double,\ double,\ double)
comment2.params=
comment2.target=double\ volume()
comment3.params=
comment3.target=double\ surfaceArea()
numComments=4
22 changes: 22 additions & 0 deletions Lab 4/Box.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

public class Box
{
private double length, width, height;

public Box(double boxLength, double boxWidth, double boxHeight)
{
length = boxLength;
width = boxWidth;
height = boxHeight;
}

public double volume()
{
return length * width * height;
}

public double surfaceArea()
{
return 2 * (length*width + length*height + width*height);
}
}
Binary file added Lab 4/BoxDemo.class
Binary file not shown.
5 changes: 5 additions & 0 deletions Lab 4/BoxDemo.ctxt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#BlueJ class context
comment0.target=BoxDemo
comment1.params=args
comment1.target=void\ main(java.lang.String[])
numComments=2
Loading