Neelu
Neelu
1.Arrays.java
2.Account.java
i)
public class Account {
int acc_no;
int balance;
String name;
public Account(int ac_no,int balance,String name){
this.acc_no=ac_no;
this.balance=balance;
this.name=name;
}
void deposit(int amount){
this.balance+=amount;
}
void withDraw(int amount){
if(this.balance<amount){
System.out.println("Can't withdraw the amount, Insufficient balance");
}
else{
System.out.println("amout withdraw successfull");
this.balance-=amount;
}
}
String getName(){
return this.name;
}
int getAccno(){
return this.acc_no;
}
int getBalance(){
return this.balance;
}
}
2. ii) AccountTest.java
3. i) Customer.java
3. ii) TestCustomer.java
public class TestCustomer {
public sta c void main(String[] args) {
Customer c=new Customer(1000,5000,"razeen");
System.out.println("The account number is: "+c.getAccno());
System.out.println("The name of the customer is : "+c.getName());
System.out.println("The balance in the beginning of the month :"+c.getBeginBalance());
c.buyProduct(500);
c.buyProduct(400);
c.buyProduct(1000);
c.buyProduct(2000);
c.getNewBal();
System.out.println(c.getNewBalance());
}
}
4. i) Employee.java
4.
ii)EmployeeTest.java
5.
i)Invoice.java
5.
ii)InvoiceTest.java
6.TestDate.java
class Date {
int date;
int month;
int year;
Date(int date, int month, int year) {
this.year = year;
if (month <= 12) {
if (month == 2) {
if (this.year % 400 == 0 || (this.year % 4 == 0 && this.year % 100 != 0)) {
System.out.println(month);
if (date <= 29) {
this.date = date;
this.month=month;
} else {
this.date = -1;
this.month=-1;
}
} else {
if (date <= 28) {
this.date = date;
this.month=month;
} else {
this.date = -1;
this.month=-1;
}
}
} else if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10
|| month == 12) {
if (date <= 31) {
this.date = date;
this.month=month;
} else {
this.date = -1;
this.month=-1;
}
} else {
if (date <= 30) {
this.date = date;
this.month=month;
} else {
this.date = -1;
this.month=-1;
}
}
} else {
this.month = -1;
this.date = -1;
}
}
int getDate() {
return this.date;
}
int getMonth() {
return this.month;
}
int getYear() {
return this.year;
}
void setDate(int date) {
if (this.month == 2) {
if (this.year % 400 == 0 || (this.year % 4 == 0 && this.year % 100 != 0)) {
if (date <= 29) {
this.date = date;
} else {
System.out.println("can't insert the date beacuse it is a leap year");
}
} else {
if (date <= 28) {
this.date = date;
} else {
System.out.println("can't insert the date beacuse it is not a leap year");
}
}
}
else if (this.month == 1 || this.month == 3 || this.month == 5 || this.month == 7 || this.month == 8
|| this.month == 10 || this.month == 12) {
if (date <= 31) {
this.date = date;
} else {
System.out.println("can't set date becuase it exceeds the allocated date for a month");
}
}
else{
if (date <= 30) {
this.date = date;
} else {
System.out.println("can't set date becuase it exceeds the allocated date for a month");
}
}
}
void setMonth(int month){
if(month>=1 && month<=12){
this.month=month;
}
else{
System.out.println("can't set month");
}
}
void setYear(int year){
this.year=year;
}
void displayDate(){
System.out.println("The objects date is :");
System.out.println(this.month+"/"+this.date+"/"+this.year);
System.out.println(this.month+"-"+this.date+"-"+this.year);
System.out.println(this.month+":"+this.date+":"+this.year);
System.out.println(this.month+"."+this.date+"."+this.year);
}
}
public class TestDate {
public sta c void main(String[] args) {
Date d=new Date(4,2,2001);
System.out.println("The date is :");
System.out.println(d.getDate());
System.out.println(d.getMonth());
System.out.println(d.getYear());
d.setDate(30);
d.setMonth(2);
d.setYear(2011);
d.displayDate();
}
}