Tuesday 26 July 2022

Python Project | Banking System | Project on Banking System using python

 

PYTHON PROJECT

Banking System


import csv
import pandas as pd
import matplotlib.pyplot as plt
import sys
import datetime

found=False
def newAcc():
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    AccNum=[]
    Name=[]
    BalAmt=[]
    WithAmt=[]
    DepositAmt=[]
    number=int(input("Enter the number of Account Holder : "))
    for i in range(number):
        accno=(input("Enter Account Number : "))
        name=input("Enter FullName : ")
        deposit=(input("Enter Deposit Amount : "))
        AccNum.append(accno)
        Name.append(name)
        BalAmt.append(deposit)
        WithAmt.append(0)
        DepositAmt.append(deposit)
        withAmtdate=['0000:00:00  00:00']
    dict={'AccountNumber':AccNum,'Name':Name,'DepositAmount':DepositAmt,'WithdrawAmount': WithAmt, 'BalanceAmount' : BalAmt,'DepositAmtDate': [datetime.datetime.now()],'WithdrawAmtDate':withAmtdate  }
    df1=pd.DataFrame(dict)
    dfNew=df.append(df1,ignore_index=True)
    dfNew.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    print(dfNew)
    
def displayRecord():
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    print(df)
    
    
def searchRecord():
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    accno=int(input("Enter Account Number to be Searched...: "))
    print(df[df['AccountNumber'] == accno])
    
       
def depositAmt():
    found=False
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    accno=int(input("Enter Account Number :  "))
    depositamt=int(input("Enter Amount to be Deposited.. : "))
    for r,row in df.iterrows():
        if (row['AccountNumber'] == accno):
            df.at[r,'DepositAmount']= row['DepositAmount']+depositamt
            df.at[r,'BalanceAmount'] = row['BalanceAmount'] + depositamt
            df.at[r,'DepositAmtDate']=datetime.datetime.now()
            found=True
            break
            
    if(found==True):
        print("Amount Deposited Successfully...") 
    else:    
        print("Account Number Invalid.")
        
    
    df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
    print(df[df['AccountNumber']==accno])
    
    
def withdrawAmt():
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    accno=int(input("Enter Account Number :  "))
    withdrawamt=int(input("Enter Amount to be Withdrawl.. : "))
    for r,row in df.iterrows():
        if (row['AccountNumber']==accno):
            df.at[r,'WithdrawAmount']= withdrawamt
            df.at[r,'BalanceAmount'] = row['BalanceAmount'] - withdrawamt
            df.at[r,'WithdrawAmtDate']=datetime.datetime.now()
            found=True
            break
            
    if(found==True):
        print("Amount Withdrawl Successfully...") 
    else:    
        print("Account Number Invalid.")
    
    df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
    print(df[df['AccountNumber']==accno])
    
def updateRecord():
    found=False
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    accno = int(input("Enter Account Number :  "))
    for r,row in df.iterrows():
        if row['AccountNumber']==accno:
            print(df[df['AccountNumber']==accno])
            print("You cannot modify the Account Number. ")
            pwd=input("To update the record Please enter the password : ")
            if(pwd=='Admin'):
                newname=input("Enter New Name")
                newDepositamt=int(input("Enter Deposit Amount : "))
                newWithdrawamt=int(input("Enter Withdrawl Amount : "))
                newBalance= newDepositamt-newWithdrawamt
                df.at[r,'DepositAmount'] = newDepositamt
                df.at[r,'WithdrawAmount']= newWithdrawamt
                df.at[r,'BalanceAmount'] = newBalance                      
                
                found=True
            else:
                print("Password Invalid.")
    if(found==True):
        print("Record Updated Successfully...") 
    else:    
        print("Account Number Invalid.")
    
    df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)
    print(df[df['AccountNumber']==accno])
            
def deleteRecord():
    found=False
    
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    accno = int(input("Enter Account Number :  "))
    for r,row in df.iterrows():
        if (row['AccountNumber']==accno):
            df.drop(df.index[r],axis=0)
            found=True
    if(found==True):
        print("Record Deleted Successfully...") 
    else:    
        print("Account Number Invalid.")
    
    df.to_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv",index=False)

def lineGraph():
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    DepositAmt=[]
    WithdrawAmt=[]
    BalAmt=[]
    name=[]
    for c,col in df.iterrows().head(5):
        n=col['Name']
        ba=col['BalanceAmount']
        name.append(n)
        BalAmt.append(ba)
    plt.plot(name,BalAmt,'r',linewidth=2,linestyle='solid')
    plt.xlabel('Customer Name')
    plt.ylabel('Balance Amount')
    plt.show()
        
def barGraph():
    df=pd.read_csv("C:\\Users\\91971\\Desktop\\BankDetails.csv")
    DepositAmt=[]
    WithdrawAmt=[]
    BalAmt=[]
    name=[]
    for r,row in df.iteritems():
            DepositAmt=row['DepositAmount']
            WithdrawAmt=row['WithdrawAmount']
            BalAmt=row['BalanceAmount']
            name=row['Name']
            found=True
    if(found==True):
        plt.bar(Name,DepositAmt,'r')
        plt.xlabel('Customer Name')
        plt.ylabel('Deposit Amount')
        plt.show()
    else:
        print("Invalid Access")    
        
def dataVisual():
    print("Data Visualization")
    print("Menu\n 1. Line Graph\n 2. Bar Graph \n ")
    choice= int(input("Enter your choice"))
    if choice==1:
        lineGraph()
    elif choice==2:
        barGraph()
    else:
        print("Please Enter Correct Choice...")

while True:
    print("Banking System")
    print("Menu \n 1.Open New Account \n 2.Deposit Amount \n 3.Withdraw Amount  \n 4.Update Record\n 5.Dispaly All Record\n 6.Search Record\n 7.Delete Record\n 8.Data Visualization\n 9. Exit ")
    choice=int(input("Enter your Choice"))
    if choice==1:
        newAcc()
    elif choice==2:
        depositAmt()
    elif choice==3:
        withdrawAmt()
    elif choice==4:
        updateRecord()
    elif choice==5:
        displayRecord()
    elif choice==6:
        searchRecord()
    elif choice==7:
        deleteRecord()
    elif choice==8:
        dataVisual()
    elif choice==9:
        sys.exit()
    else:
        sys.exit()





    

Java Loop Questions | Loop Questions with Answers

 

Java Loop Questions | Loop Questions with Answers


Q1. What will be the value of A and B after execution of the following code ?

int A=100, B;
for (B=10; B<=12; B++)
{
A+=B;
}
JOptionPane.showMessageDialog(this, “A:” + A+ “B:” +B+ “”);

Output:
A: 133      B: 13

Q2. What will be the content of the jTextArea1 after executing the following code (Assuming that the jTextArea1 had no content before executing this code ) ?

for(int i=2; i<=5;i++)
{
jTextArea1.setText(jTextArea1.getText() + “ “ + Integer.toString(i*i));
}

Output:
4
9
16
25

Q3. What will be displayed in of jTextField1 after executing the following code ?

int N=20;
N=N+1;
if(N<21)
      jTextField1.setText(Integer.toString(N+10));
else
     jTextField1.setText(Integer.toString(N+15));

Output :

Q4. The following code has some errors. Rewrite the correct code.

Int P=3; Sum=0;
{
 Sum=P;
P+=3;
}
while(P=<12)
jTextField1(Integer.toString(Sum));

Output:

int P=3Sum=0;
do
{
Sum=P;
P+=3;
}while(P<=12);
jTextField1.setText(Integer.toString(Sum));

Q5. Rewrite the code

Int total=0,jump=5;
Int I;
For (i=0;I=<5;I++)
{
Jump+=5;
Total+=jump;
}
jTextArea1.showText(“”+total);

Output:

int total=0,jump=5;
int I;
for (I=0;I<=5;I++)
{
Jump+=5;
Total+=jump;
}
jTextArea1.append(“”+total);




Q6. Rewrite the following program code after finding errors.
Int k=2;
sum=0;
{
Sum=k;
K+=3;
}
While (k=<20)
jTextField1 (Integer.toString(sum));

Output:

int k=2, sum=0;
do
{
sum=k;
k+=3;
}
while(k<=20);
jTextField1.setText (Integer.toString(sum));


Q7. Rewrite the correct code.
Int sum=0; step=5;
Int I;
for(i=0; i=<5;i++)
{
Step +=5;
Sum+=step;
}
jTextArea1.showText(“” +sum);

Output:

int sum=0; step=5;
int i;
for(i=0; i=<5;i++)
{
step +=5;
sum+=step;
}
jTextArea1.setText(“” +sum);


Q8. What will be the values of variables ‘m’ and ‘n’ after the execution of the given code?

int m, n=0;
for (m=1; m<=4; m++)
{
n+=m;
n--;
}

Output:
m=5
n=6

Q9. What is Java do loop? Explain with an example .

Ans. A Java do loop is similar to the java while loop, except that the while test happens at the bottom  of the loop. This means that the loop always executes atleast once.

The syntax of a do loop in java is :

do
{
// statements
}while( condition );

Here is a java do loop that prints the number 1 even though the test fails.

int loopvar=1; // Declare and initialize the loop counter
do {
   jTextField1.setText(String.valueOf(loopvar)); // prints the variable
   loopvar=loopvar+1; // Increment the loop counter
}while(loopvar>=10); //test the loop

Q10. What is Java while loop ? Explain with example.

Ans. A java while loop is a looping construct which continually executes a block of statements while a condition remains true. The syntax of a while loop in java is:

while(expression/condition)
{
  // statements
}

Here is java while loop that prints the numbers 1 through 10.

int loopvar=1; // Declare and initialize the loop counter
while(loopvar<=10) // test the loop
{
jTextField1.setText(String.valueOf(loopvar)); // prints the variable
loopvar=loopvar+1; // Increment the loop counter
}

Q11. Write a For loop to print out the values 1 to 10 on separate lines.

Ans.

int loop;
for(loop=1; loop<=10; loop= loop+1)
{
  System.out.println(loop);
}

Q12. Write a for loop program to print pattern as :

1
22
333
4444
55555

Ans. 

int loop=1;
for(loop=1; loop<=5; loop=loop+1)
{
    for(int count=1; count<=loop; count=count+1)
    {
       jTextArea1.append(String.valueOf(loop));
    }   
    jTextArea1.append("\n");
}


Q13. Write a for loop which sums all values between 10 and 100 into a variable called total. Assume that total has not been initialized to 0.

Ans. 

int loop,total;
for(loop=10, total=0;loop<=100; loop= loop+1)
{
  total=total+loop;
}


Q14. Write a program to print out the character set from A-Z using for loop.

Ans.

char ch;
for(ch='A'; ch<='Z'; ch=ch+1)
{
  jTextArea1.append(String.valueOf(ch));
}

Q15. Find the output of the following program :
       
  for(int i=0; i<10; i++)
              jTextArea1.append(String.valueOf(++i)+"\n");

Ans.

1
3
5
7
9

Thursday 23 December 2021

Mysql Questions | Questions with Answers in Mysql

 

Mysql Questions | Questions with Answers in Mysql


Q1. What Mysql command will be used to open an already existing database “Library”?

Ans. Use Library;


Q2. The name column of a table members is given below:

Name
Akash
Amit
Rajiv
Preeti








Based on the information, find the output of the following queries:
a.       Select name from members where name like ‘%v’;
b.       Select name from members where name like ‘%e%’;


Ans.


a.






Name
Rajiv




b.
Name
Preeti




Q3. A table ‘Trains’ in a database has degree 3 and cardinality  8. What is the number of rows and columns in it?

Ans.
Number of Rows : 8
Number of Columns : 3

Q4. Difference between Primary key and Unique.

Ans. Primary key identifies uniquely each record in the table. It cannot contain null and duplicate values.

Unique also identifies uniquely each record in the table. It can contain null values but cannot contain duplicate values.


Q5. Vinay, a student of class X1, created a table ‘Result’.Grade is one of the column of this table. To find the details of students whose grades have not been entered, he wrote the following Mysql query which did not give the desired result.
Select * from result where grade=’Null’

Ans.
Select * from result where grade is null;

Q6. Write Mysql command to display the list of existing databases.

Ans.
Show databases;

Q7. Mr.William wants to remove all the rows from Inventory table to release the storage space, but he does not want to remove the structure of the table. What Mysql statement should he use?

Ans.
Delete from inventory;

Q8. Mr.Mittal is using a table with following columns:
        Name, class, stream,stream_id,stream_name
He needs to display names of students who have not been assigned any stream or have been        assigned a stream_name that ends with ‘Computers’.
He wrote the following command which did not give the desired output.
Select name,class from students where stream_name=null or stream_name like ‘%computers’;
Help Mr.Mittal to run the query by removing the error and write correct query.

Ans.
Select name , class from students where stream_name is null or stream_name like ‘%computers’;

Q9. Ms.Nidhi wants to remove the entire content of a table ‘Backup’ alongwith its structure to release the storage space.What Mysql statement should she use?

Ans.
Drop table backup;

Q10. What is the purpose of Drop Table command in Mysql? How is it different from Delete command.

Ans.
Drop table Command is used to remove the entire content of a table alongwith its structure.
Delete table command is used to remove the rows from the table.

Q11. Consider the table Result given below .

Table: Result
No
Name
Stipend
Average
Division
Subject
1
Amit
400
49
Third
English
2
Sneh
680
34
First
Maths
3
Vijay
500
56
Second
Science
4
Preeti
200
78
First
Accounts
5
Sunita
400
65
First
History
6
Suman
550
45
Third
Computer


a.       To list the names of those students, who have obtained division as first in the ascending order of name.
b.       To display a report listing name,subject and annual stipend received assuming that the stipend column has monthly stipend.
c.       To count the number of students who have either accounts or computer as subject.
d.       Select avg(stipend) from result where division=’third’;
e.       Select count(distinct subject) from result;
f.        Select min(average) from result where subject=’English’;

Ans.
a.       Select name from result where division=’third’ order by name asc;
b.       Select name , subject , stipend*12 as ‘Annual Stipend’ from result ;
c.       Select count(*) from result where subject=’accounts’ or subject=’computer’;
Or you can write as
Select count(*) from result where subject in (‘accounts’,’Computer’);
d.        Avg(stipend)=475
e.       6
f.        49


Q12. What is the purpose of Alter Table command and how is differ from Update command?

Ans.
Alter Command is used to modify the structure of the table. It can be in several ways like adding or dropping column, change the existing column name or definition or datatype, adding or dropping constraints such as primary key, unique, default etc..

For example:

Alter table table_name
Add primary key (id);

Update Command  is used to modify or change the existing record in the table.

For example:

Update table_name
Set salary=20000 where eid=011;

Q13.What is the purpose of Group By Clause and how is differ from Order By Clause?

Ans.
Group By Clause is used to sort or group a number of rows together so as to apply aggregate functions. It is used to sort and also find aggregate functions of each group.
For example : select max(salary) from employee group by department;

Order By Clause is used to only sort the rows in ascending or descending order.
For example : Select * from employee order by salary asc.

Q14. Table Hospital has 4 rows and 5 columns. What is the Cardinality and degree of this table.?

Ans.
The Cardinality is 4
The Degree is 5

Q15. Differentiate between Having and Where with Select query command.

Ans.
The Where with Select Query Command specifies the search condition used to determine the data that will appear in the result table. It is used to specify the rows you want to retrieve.
For example: Select * from student where grade=’A’;
Having Clause restricts grouped rows that appear in the result table. Groups are specified with the group by clause. You can combine search conditions with the And, Or, Not Operations.
For example: Select avg (fees) from student group by grade having sum(fees)>1500;

Q16. How many types of functions are there in sql and what are they?

Ans.
Sql functions can be divided broadly into four categories:
a.       Character Functions
b.       Data Conversion Functions
c.       Date Functions
d.       Numeric Functions

Q17. Give the examples of character functions.

Ans. Character Functions :
LCase() : It is used to convert all characters into lower case character.
UCase() : It is used to convert all the characters into upper case character.

Q18. Give at least four examples of numeric functions.

Ans. Numeric Functions: Round(),Mod(),Power()

Q19. Which function returns the remainder of numeric expression.

Ans. Mod() function

Q20. Write the function which returns the character string by converting each character to lower character.

Ans. Lower() or LCase() function.

Q21. Which function returns the length of a string.

Ans. Length() function

Q22. Write the function name which  returns specified number of character from a string.

Ans. SubString() function

Q23. How will you count number of characters in a character expression.

Ans. Length() function

Q24. How will you get computer date?

Ans. Sysdate() and Curdate() function

Q25. How will you remove leading and trailing blanks from a character string expression P, where P=”Amit#Jain####” (Here # denote as blank spaces).

Ans. Trim() function is used to remove leading and trailing blanks.
Select trim(“Amit#Jain####”);

Q26. What will be the output of
a.       Select round(124.44)+mod(1200.87,3);
b.       Select mod(30.500,5)+round(100.50,1);

Ans.
a.       124.87
b.       101

Q27. Table : Employee

Empno
Ename
Job
MGR
Hiredate
Sal
Comm
Dept
7369
Amit
Clerk
7902
1980-12-17
2800
Null
20
7499
Sneh
Salesman
7698
1981-02-20
3600
300
30
7521
Preeti
Salesman
7698
1981-02-22
5250
500
30
7566
Vinay
Manager
7839
1981-04-02
4975
Null
20
7654
Deepak
Salesman
7698
1981-09-29
6250
1400
30
7698
Vishal
Manager
7839
1981-05-01
5850
Null
30
7782
Neeraj
Manager
7839
1981-06-09
2450
null
10

Write some sql commands
a.       Simple Select query questions.
·         To select all the columns of the above table.
·         To list the name and employee number from the above table.
·         To list all names, hiredate and salary of all employee.
Ans:
a.        
·         Select * from employee;
·         Select Ename, Empno from employee;
·         Select Ename,Hiredate, Sal from employee;


Q28. 

Recent Post

Python Project | Banking System | Project on Banking System using python

  PYTHON PROJECT Banking System import csv import pandas as pd import matplotlib.pyplot as plt import sys import datetime found=False def ne...