Sei sulla pagina 1di 15

MINI PROJECT- Employee Information

package
employee
;
public class employees {
public static void main(String[] args)
{
int[] Emp_No={1001,1002,1003,1004,1005,1006,1007};
String[] Emp_Name={"Anish","Sushma","Rahul","Chahat","Ranjan","Suman","Tanmay"};
// String[]
Join_Date={"01/04/2009","23/08/2012","12/11/2008","29/01/2013","16/07/2005","1/1/2000","12/06/20
6"};
char[] Design_Code={'e','c','k','r','m','e','c'};
String[] Dept={"R&D","PM","Acct","FrontDesk","Engg","Manufacturing","PM"};
long[] Basic={20000,30000,10000,12000,50000,23000,29000};
long[] HRA={8000,12000,8000,6000,20000,9000,12000};
long[] IT={3000,9000,1000,2000,20000,4400,10000};

//int id=Integer.parseInt(args[0]);
int i,flag=0;
long sal=0;
String des="";
for(i=0;i<7;i++)
{
if(Integer.parseInt(args[0])==Emp_No[i])
{
switch(Design_Code[i]){
case 'e': des="Engineer";
sal=Basic[i]+HRA[i]+20000-IT[i];break;
case 'c': des="Consultant";
sal=Basic[i]+HRA[i]+32000-IT[i];break;
case 'k': des="Clerk";
sal=Basic[i]+HRA[i]+12000-IT[i];break;
case 'r': des="Receptionist";
sal=Basic[i]+HRA[i]+15000-IT[i];break;
case 'm': des="Manager";
sal=Basic[i]+HRA[i]+32000-IT[i];break;

System.out.println("Emp
No.\t\tEmpName\t\tDepartment\t\tDesignation\t\tSalary");
System.out.print(Emp_No[i]+"\t\t"+Emp_Name[i]+"\t\t"+Dept[i]
+"\t\t"+des+"\t\t"+sal);

}
else
flag++;
}
if(flag==7)
System.out.print("There is no employee with
empid:"+Integer.parseInt(args[0]));
}
}

MINIPROJECT- Video Rental Inventory System

package
inheritance
;
import java.util.*;
class Video{
String title;
boolean[] flag=new boolean[10];

int[] user_rating=new int[10];


void being_checkedout(int i)
{
if(flag[i]==true)
flag[i]=false;
}
void being_returned(int j)
{
if(flag[j]==false)
flag[j]=true;
}
void receive_a_rating(int n,int no)
{
user_rating[n]=no;
}
}
class VideoStore extends Video
{
Video obj=new Video();
String[] videos=new String[10];
int[] rate=new int[10];
int i=0;

void addVideo(String title)


{

videos[i++]=title;
}
void checkOut(String nm)
{

int j,index=0;
for(j=0;j<3;j++)
{
if(videos[j].equals(nm))
{
index=j;
}
}
being_checkedout(index);
}
void returnVideo(String nm)
{
int j,index=0;
for(j=0;j<3;j++)
{
if(videos[j].equals(nm))
{
index=j;
}
}
being_returned(index);
}
void receiveRating(int n, int no )
{
rate[n]=no;
receive_a_rating(n,no);
}
void listInventory()
{
int i;

for(i=0;i<3;i++)
{

if(flag[i]==true)
System.out.println(videos[i]+" " +flag[i]);
}

}
}
public class store extends VideoStore{
public static void main(String args[])
{
VideoStore o=new VideoStore();
// VideoStore o1=new VideoStore();
Arrays.fill(o.flag, true);
//VideoStore o2=new VideoStore();
o.addVideo("The Matrix");
o.addVideo("Godfather II");
o.addVideo("Star War Episode IV: A New Hope");
o.receiveRating(0, 4);
o.receiveRating(1, 3);
o.receiveRating(2, 5);
o.checkOut("The Matrix");
o.checkOut("Godfather II");
o.checkOut("Star War Episode IV: A New Hope");
o.returnVideo("The Matrix");
o.returnVideo("Godfather II");
o.returnVideo("Star War Episode IV: A New Hope");
o.checkOut("Godfather II");
o.listInventory();

}
}

 © 2019 GitHub, Inc.
MINIPROJECT- Interest Calculator

import java.util.*;
interface Account{
double interestrate=0.0;
double amount=0.0;
abstract double calculateInterest();
}
class SBAccount implements Account{
private double interestrate;
private double amount;
double gainedInterest;
public double calculateInterest(){
Scanner sc=new Scanner(System.in);
System.out.println("Enter the average in your account");
amount=sc.nextDouble();
System.out.println("Enter 1 for Normal account or 2 for NRI account");
int typeofacc=sc.nextInt();
if(amount <= 0)
{
System.out.println("Please enter Valid Amount.");
}
else{
if(typeofacc==1){
gainedInterest=((amount*4)/100);
System.out.println("Interest gained "+gainedInterest);
}
else if(typeofacc == 2){
gainedInterest=((amount*6)/100);
System.out.println("Interest gained "+gainedInterest);
}
else{
System.out.println("invalid selection");
}
}
return 0;
}
}
class FDAccount implements Account{
private double interestrate;
private double amount;
private int noOfDays;
int ageOfACHolder;
double gainedInterest;
public double calculateInterest(){
System.out.println("Enter the FD amount:");
Scanner sc=new Scanner(System.in);
amount=sc.nextDouble();
System.out.println("Enter the no of days:");
noOfDays=sc.nextInt();
System.out.println("Enter your age:");
ageOfACHolder=sc.nextInt();
if(amount<10000000){
if(noOfDays>=7 && noOfDays<=14){
if(ageOfACHolder<=60){
interestrate=4.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else{
interestrate=5.0;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
}
else if(noOfDays>=15 && noOfDays<=29){
if(ageOfACHolder<=60){
interestrate=4.75;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else{
interestrate=5.25;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
}
else if(noOfDays>=30 && noOfDays<=45){
if(ageOfACHolder<=60){
interestrate=5.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else{
interestrate=6.00;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
}
else if(noOfDays>=46 && noOfDays<=60){
if(ageOfACHolder<=60){
interestrate=7;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else{
interestrate=7.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
}
else if(noOfDays>=61 && noOfDays<=184){
if(ageOfACHolder<=60){
interestrate=7.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else{
interestrate=8.00;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
}
else if(noOfDays>=185 && noOfDays<=365){
if(ageOfACHolder<=60){
interestrate=8.00;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else{
interestrate=8.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
}
else {System.out.println("Please Provide Valid days.");}
}
else{
if(noOfDays>=7 && noOfDays<=14){
interestrate=6.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else if(noOfDays>=15 && noOfDays<=29){
interestrate=6.75;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else if(noOfDays>=30 && noOfDays<=45){
interestrate=6.75;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else if(noOfDays>=46 && noOfDays<=60){
interestrate=8.00;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else if(noOfDays>=61 && noOfDays<=184){
interestrate=8.50;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else if(noOfDays>=185 && noOfDays<=365){
interestrate=10.00;
gainedInterest=(amount*interestrate)/100;
System.out.println("Interest gained is: "+gainedInterest);
}
else {System.out.println("Please Provide Valid days.");}
}
return 0.0;}
}
class RDAccount implements Account{
private double interestRate;
private double amount;
private double monthlyAmount;
private int ageOfACHolder;
private int noOfMonths;
public double calculateInterest(){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the RD amount: ");
amount = sc.nextDouble();
System.out.println("Enter the number of months, either 6 or 9 or 12 or 15 or 18 or 21");
noOfMonths = sc.nextInt();
System.out.println("Enter your age: ");
ageOfACHolder = sc.nextInt();
if(amount <= 0.0){
System.out.println("Invalid RD Amount");
}
else{
if (noOfMonths == 6) {
if(ageOfACHolder <= 55){
interestRate = 7.5;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
else{
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
}
else if (noOfMonths == 9) {
if(ageOfACHolder <= 55){
interestRate = 7.75;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
else{
interestRate = 8.25;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
}
else if (noOfMonths == 12) {
if(ageOfACHolder <= 55){
interestRate = 8.0;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
else{
interestRate = 8.5;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
}
else if (noOfMonths == 15) {
if(ageOfACHolder <= 55){
interestRate = 8.25;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
else{
interestRate = 8.75;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
}
else if (noOfMonths == 18) {
if(ageOfACHolder <= 55){
interestRate = 8.5;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
else{
interestRate = 9.0;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
}
else if (noOfMonths == 21) {
if(ageOfACHolder <= 55){
interestRate = 8.75;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
else{
interestRate = 9.25;
double gainedInterest = (amount * interestRate)/100;
System.out.println("Interest Gained is : "+gainedInterest);
}
}
else System.out.println("Please Provide Valid Months.");
}
return 0.0;
}
}
public class InterestCalculator{
public static void main(String args[]){
try{
FDAccount fda=new FDAccount();
SBAccount sba=new SBAccount();
RDAccount rda=new RDAccount();
System.out.println("MAIN MENU \n 1. Interest Calculator - SB \n 2. Interest Calculator - FD \n 3.
Interest Calculator - RD \n 4. Exit");
System.out.println("Enter your option(1..4): ");
Scanner sc=new Scanner(System.in);
int choice=sc.nextInt();
if(choice==1){
sba.calculateInterest();
}
else if(choice==2){
fda.calculateInterest();
}
else if(choice==3){
rda.calculateInterest();
}
else if(choice==4){
System.out.println("exiting");
System.exit(0);
}
else
System.out.println("Please enter valid choice");
}
catch(Exception e){
System.out.println("Error occurred at: "+e);
}
}
}

 © 2019 GitHub, Inc.
MINIPROJECT- Bank

Account.java

package
com.wipro.bank.acc
;
public abstract class Account {
int tenure;
float principal;
float rateOfInterest;
public void setInterest(int age, String gender){
if(gender.equals("Male")){
if(age<60){
this.rateOfInterest = 9.8f;
}
else{
this.rateOfInterest = 10.5f;
}

}
if(gender.equals("Female")){
if(age<58){
this.rateOfInterest = 10.2f;
}
else{
this.rateOfInterest = 10.8f;
}
}
}
public float calculateMaturityAmount(float
totalPrincipleDeposited,
float maturityInterest){
return totalPrincipleDeposited+maturityInterest;

}
public abstract float calculateInterest();
public abstract float calculateAmountDeposited();
}
RDAccount.java

package
com.wipro.bank.acc
;
public class RDAccount extends Account {
public RDAccount(int tenure, float principal) {
this.principal = principal;
this.tenure = tenure;
// TODO Auto-generated constructor stub
}
@Override
public float calculateInterest() {
// TODO Auto-generated method stub
float temp =(float)
(this.principal*(Math.pow((float)(1+this.rateOfInterest/(float)4), this.tenure*4)-1));
return temp;
}
@Override
public float calculateAmountDeposited() {
// TODO Auto-generated method stub
return this.principal*this.tenure*12;
}
}

 © 2019 GitHub, Inc.

BankValidationException.java

package
com.wipro.bank.exception
;
public class BankValidationException extends Exception {
/**
*
*/
private static final long serialVersionUID = 1L;
public String toString(){
return "Invalid Data";
}
}
MINIPROJECT- Bank

MainClass.java

Package
com.wipro.bank.main
;
import com.wipro.bank.service.BankService;
public class MainClass {
public static void main(String[] args) {
// TODO Auto-generated method stub
int tenure = 5;
float principal = 1000;
int age = 23;
String gender = "Male";
BankService b=new BankService();
b.calculate(principal, tenure, age,
gender);
}
}

BankService.java

package
com.wipro.ban
k.service;
import com.wipro.bank.acc.RDAccount;
import com.wipro.bank.exception.BankValidationException;
public class BankService {
public boolean validateData(float principal, int tenure,int age, String gender){
try{
if(!(principal>=500||tenure==5||tenure==10&&gender.equalsIgnoreCase("Male")|
gender.equalsIgnoreCase("Femle")&&age>=1&&age<=100)){
throw new BankValidationException();
}
}
catch(BankValidationException e){
return false;
}
return true;
}

public void calculate(float principal,int tenure, int age, String gender){


if(validateData(principal,tenure, age, gender)){
RDAccount rda = new RDAccount(tenure,principal);
rda.setInterest(age, gender);
System.out.println(rda.calculateAmountDeposited());
float totalPrincipleDeposited = rda.calculateAmountDeposited();
int maturityInterest = tenure;
System.out.println(rda.calculateMaturityAmount(totalPrincipleDeposited,
maturityInterest));
}
}
}

Potrebbero piacerti anche