We are here with you hands in hands to facilitate your learning & don't appreciate the idea of copying or replicating solutions. Read More>>


Looking For Something at vustudents.ning.com? Click Here to Search

Assignment No. 02
SEMESTER Spring 2016
CS508- Modern Programming Languages

 

Total Marks: 20

 

Due Date: 20/07/2016

Instructions

Please read the following instructions carefully before solving & submitting assignment:

It should be clear that your assignment will not get any credit  if:

  • The assignment is submitted after due date.
  • The submitted assignment does not open or file corrupt.
  • The assignment is full or partially copied from (other student or ditto copy from handouts or internet).
  • Student ID is not mentioned in the assignment File or name of file is other than student ID.
  • The assignment is not submitted in .doc or .docx format.

Uploading instructions

Your submission must include:

 

  • Assignment should be in .doc or .docx format.
  • Save your assignment with your ID (e.g. bx020200786.doc).

Assignment submission through email is NOT acceptable

Objective

The objective of this assignment is

 

  • To be able to understand different concepts of JAVA programming language.

 

Note:

Your answer must follow the below given specifications.

  •  Font style: “Times New Roman”
  •  Font color: “Black”
  •  Font size: “12”
  •  Bold for heading only.
  •  Font in Italic is not allowed at all.
  •  No formatting or bullets are allowed to use.
  • Your answer should be precise and to the point, avoid irrelevant detail.

 

Lectures Covered: This assignment covers Lecture # 27 - 30

Deadline

Your assignment must be uploaded/submitted at or before 20/07/2016.

 

 

Question:           20 marks     

 

JAVA is purely object oriented programming language which means every variable, constant and function (method) including main function must be in some class. Furthermore, Java support only single inheritance and each supper class method except its constructors can be inherited, overloaded, or overridden in the subclass.

 

You are required to write a JAVA program which contains the following three classes.

  1. Bank_accounts   (Base class)
  2. Saving_Account (Subclass of Bank_accounts)
  3. Saving_Acc_Test (main function class)

The base class Bank_accounts should define the attributes/variables for account title, Balance, interest (interest should be in amount).

The base class must contain the methods Withdraw(), Deposit() and add_interest().

 

The subclass Saving_Account should define an attribute for interest rate (Annual interest  in percentage). This class should inherit Withdraw() method, overload Deposit() method and override add_interest () method of base class. Furthermore, the deposit method should deposit some interest (in percentage) on each deposit to saving account and add_inerest method should calculate annual interest on the basis of interest rate.

 

Saving _Acc_Test class should have main function and define one object of Saving_Account class and one reference of Bank_accounts class pointing to Saving_Account class object, then call these methods of base class and subclass to implement the concept of inheritance, overloading, overriding and polymorphism.

 

You may add constructors and getter/setter functions in your classes as per your requirements.

 

Hint:  You may set any value for initial balance and deposit/withdraw any amount through these methods. Furthermore, you may call deposit method of base class with derived class object, overloaded deposit method with this object, and withdraw method to implement inheritance and overloading. Similarly call the override method with base class reference to implement overriding and polymorphism.

 

Note 1: You can compile/check your program online through the link http://www.ideone.com/  for syntax errors.

 

Note 2: Once you complete assignment, upload your code in a single MS word (.doc or .docx) file on VULMS.

+ Click Here To Join also Our facebook study Group.

..How to Join Subject Study Groups & Get Helping Material?..


See Your Saved Posts Timeline

Views: 2062

.

+ http://bit.ly/vucodes (Link for Assignments, GDBs & Online Quizzes Solution)

+ http://bit.ly/papersvu (Link for Past Papers, Solved MCQs, Short Notes & More)

Replies to This Discussion

is me error han, 

is net beam pr ni chaal raha..

Is ki main class b chahyee... 

plz full correct solution ki zip file agr dy do to...

class Bank_accounts {
protected String accountTitle;
protected double balance = 700;
protected double interest = 0.0;

public String getAccountTitle() {
return accountTitle;
}
public void setAccountTitle(String accountTitle) {
this.accountTitle = accountTitle;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getInterest() {
return interest;
}
public void setInterest(double interest) {
this.interest = interest;
}
public void withdraw(double amnt){
balance = balance - amount;
}
void deposit(double amount){
balance = balance + amount;
}
void add_interest(){
interest = 20.0;
}
}
class Saving_Account extends Bank_accounts{
private double annualInterestRate = 0.0;

public double getAnnualInterestRate() {
return annualInterestRate;
}
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
void deposit(double amount, double intrst){
interest = interest + (amount * (intrst/100));
balance = balance + amount;
add_interest();
}
void add_interest(){
annualInterestRate = (interest *12)/100;
}

}
class Saving_Acc_Test {

public static void main(String args[]){
Bank_accounts b = new Bank_accounts();
b.accountTitle = "Ali Zaman";
b.deposit(50.0);
b.withdraw(10.0);

System.out.println("Account Title" + b.getAccountTitle());
System.out.println("Initial Balance " + b.balance);
System.out.println("Balnance after deposit and withdraw transaction for account " + b.getAccountTitle()+" :" + b.getBalance());

Saving_Account s = new Saving_Account();
s.accountTitle = "Sheraz Hussain";
s.setBalance(600.0);
s.deposit(50.0,0.5);
s.deposit(50.0);
s.withdraw(10.0);
double bal = s.getBalance() + (s.getBalance() *s.getAnnualInterestRate() );
System.out.println("Account Title" + s.getAccountTitle());
System.out.println("Initial Balance " + s.balance);
System.out.println("Balnance after getting annual Interest " + bal);
}
}

RSS

© 2019   Created by + M.Tariq Malik.   Powered by

Promote Us  |  Report an Issue  |  Privacy Policy  |  Terms of Service