Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ***** PROBLEM 3 ********
- public class BankAccount{
- private String name, address, accountID;
- private double balance;
- public String getName(){
- return name;
- }
- public void setName(String name){
- this.name = name;
- }
- public String getAccountID(){
- return accountID;
- }
- public String getAddress(){
- return address;
- }
- public double getBalance(){
- return balance;
- }
- public void setAccountID(String accountID){
- this.accountID = accountID;
- }
- public void setAddress(String address){
- this.address = address;
- }
- public void setBalance(double balance){
- this.balance = balance;
- }
- public void addInterest(){
- balance += ( balance * 7 ) / 100 ;
- }
- }
- public class Main{
- public static void main(String args[]){
- BankAccount acc1 = new BankAccount();
- BankAccount acc2 = new BankAccount();
- BankAccount acc3 = new BankAccount();
- acc1.setName("Jawad");
- acc2.setName("Farhan");
- acc3.setName("Alif");
- acc1.setBalance(100);
- acc1.addInterest();
- System.out.println(acc1.getName());
- System.out.println(acc1.getBalance());
- }
- }
- ******* PROBLEM 4 **********
- public class Student{
- private String name, id, address;
- private double cgpa;
- public String getName(){
- return name;
- }
- public String getID(){
- return id;
- }
- public String getAddress(){
- return address;
- }
- public double getCGPA(){
- return cgpa;
- }
- public void setName(String name){
- this.name = name;
- }
- public void setID(String id){
- this.id = id;
- }
- public void setAddress(String address){
- this.address = address;
- }
- public void setCGPA(double cgpa){
- this.cgpa = cgpa;
- }
- }
- public class MainStudent{
- public static void main(String args[]){
- Student[] arr = new Student[10];
- arr[0] = new Student();
- arr[0].setCGPA(3.69);
- arr[0].setName("Habibi");
- System.out.println(arr[0].getName()+" " +arr[0].getCGPA());
- }
- }
- **** PROBLEM 5 ******
- public class Triangle{
- private int a, b, c;
- public Triangle(){
- a = 0;
- b = 0;
- c = 0;
- }
- public void setTriangle(int a, int b, int c){
- this.a = a;
- this.b = b;
- this.c = c;
- }
- public boolean isRight(){
- if((b*b)+(a*a)==c*c) return true;
- else if((c*c)+(a*a)==b*b) return true;
- else if((b*b)+(c*c)==a*a) return true;
- return false;
- }
- public boolean isScalene(){
- if(a == b) return false;
- if(a == c) return false;
- if(b == c) return false;
- return true;
- }
- public boolean isIsosceles(){
- if(a==b && a!=c) return true;
- if(a==c && a!=b) return true;
- if(b==c && b!=a) return true;
- return false;
- }
- public boolean isEquilateral(){
- if(a == b && a == c) return true;
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement