0% found this document useful (0 votes)
60 views

Input Input2 Input3 Input4

The document contains code for a banking application with the following functionality: 1. It defines an Account class with attributes like account number, name, balance and methods to withdraw, deposit, check balance and print receipt. 2. The main method creates an Account object and calls the abc method passing the object. 3. The abc method displays a menu, takes the user input and calls appropriate account methods like withdraw, deposit etc. based on the input and repeats the process until user chooses to exit.

Uploaded by

PsXGaMeR
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
60 views

Input Input2 Input3 Input4

The document contains code for a banking application with the following functionality: 1. It defines an Account class with attributes like account number, name, balance and methods to withdraw, deposit, check balance and print receipt. 2. The main method creates an Account object and calls the abc method passing the object. 3. The abc method displays a menu, takes the user input and calls appropriate account methods like withdraw, deposit etc. based on the input and repeats the process until user chooses to exit.

Uploaded by

PsXGaMeR
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

import java.util.

Scanner;

public class Mainclass {


private static Scanner input =new Scanner(System.in);
private static Scanner input2;
private static Scanner input3;
private static Scanner input4;

public static void main (String[] args){

int choice=0;

System.out.println("Enter value");
choice = input.nextInt();

switch(choice){

case 1:
{ for(int i=0; i<5; i++){
for(int j=0; j<i; j++){
System.out.print("*");
}
System.out.println();
} break;
}

case 2:{
int i = 0;
do
{
int j = 0;
do
{
System.out.print("*");
j++;
}
while(j <= 1);
System.out.println();
i++;
}while(i < 5);

break;
}
case 3:
{ int j = 0;
while (j < 5)
{
int k = 0;
while(k <= j)
{
System.out.print("*");
k++;
}

System.out.println();
j++;
} break;
}
case 4:
{
int x=3, y=5;
int c,c1;
c=c1=2;

System.out.println("Arithmetic Operators");
System.out.println("Addition" + (x+y));
System.out.println("Substraction" + (x-y));
System.out.println("Multiplicaton" + (x*y));
System.out.println("division" + (x/y));
System.out.println();

System.out.println("Conditional Operators");
System.out.println("Greater than: " + (x>y));
System.out.println("Less than: " + (x<y));
System.out.println("greater than equal to: " + (x>=y));
System.out.println("less than equal to:" + (x<=y));
System.out.println("equal" + (x==y));
System.out.println("not equal" + (x!=y));
System.out.println();

System.out.println("Assignment Operators");
System.out.println("Addition assignment " + (c+=3));
System.out.println("Substraction assignment" + (c-=3));
System.out.println("Multiplicaton assignment" + (c*=3));
System.out.println("division assignment" + (c/=3));
System.out.println();

System.out.println("Inc/dec operators");
System.out.println("pre increment:" + (++c1));
System.out.println("pre decrement:" + (--c1));
System.out.println("post increment:" + (c1++));
System.out.println("post decrement:" + (c1--)); break;
}

case 5:
{
input = new Scanner(System.in);
int a,b;
System.out.println("Enter first num");
a=input.nextInt();
System.out.println("Enter second num");
b=input.nextInt();
if(a!=b)
{
System.out.println("both nos are not equal");
if(a>b)
{
System.out.println(a + " is greater than " + b);
}
else
{
System.out.println(b + "is greater than " + a);
}
}
else
{
System.out.println("both nos are equal");
}break;
}

case 6:
{
input2 = new Scanner(System.in);
int num;
System.out.println("Enter any number");
num = input2.nextInt();
if(num%2==0)
{
System.out.println("even number");
}
else {
System.out.println("odd number");
} break;
}

case 7:
{
input3 = new Scanner(System.in);

int per;
System.out.println("Enter any number");
per = input3.nextInt();
if(per>=80)
{
System.out.println("A+ grade");
}
else if(per>=70)
{
System.out.println("A grade");
}
else
{
System.out.println("Fail");

} break;
}

case 8:
{

System.out.println("exit"); break;
}
}
}
}
@@2
package test;

import java.util.Date;

import java.util.Scanner;
public class Account {
private int Acc_num;
private String name;
private double balance1,Da=0,Wa=0;

Account(int num,String name,double balance)


{
this.Acc_num=num;
this.name=name;
this.balance1=balance;
}
void withdraw(double Wa)
{
this.Wa=Wa;
balance1-=Wa;
System.out.println("Withdraw Amount "+Wa);
System.out.println("New Balance is "+balance1);

}
void deposit(double Da)
{
this.Da=Da;
balance1+=Da;
System.out.println("Deposit Amount "+Da);
System.out.println("New Balance is "+balance1);
}
void inquiry()
{
System.out.println(balance1);
}
void recipt()
{
System.out.println("\t***********");
System.out.println("\tAccount ID :"+this.Acc_num);
System.out.println("\tAccount Name :"+this.name);
if(Wa>0) {
System.out.println("\tWithDraw ammount :"+Wa);
}
else if(Da>0)
{
System.out.println("\tDeposit ammount :"+Da);
}
System.out.println("\tBalance:"+balance1);
System.out.println("\t***********");
System.out.println("\tThank You For Using Our Bank!");

}
void Mainmenu()
{
System.out.println("1- Withdraw");
System.out.println("2- Deposit");
System.out.println("3- BalanceInquiry");
System.out.println("4- Get Recipt");
System.out.println("5- Exit");
}
public void abc(Account acc) {
Mainmenu();
@SuppressWarnings("resource")
Scanner s=new Scanner (System.in);
int x=s.nextInt();
while(x!=0)
{
switch(x)
{
case 1:
System.out.println("Enter ammount to withdraw");
double a=s.nextInt();
acc.withdraw(a);
break;
case 2:
System.out.println("Enter ammount to deposit");
double d=s.nextInt();
acc.deposit(d);
break;
case 3:
acc.inquiry();
break;
case 4:
acc.recipt();
System.exit(5);
break;
case 5:
System.exit(5);
break;
}
acc.Mainmenu();
x=s.nextInt();
}

package test;

import java.util.Scanner;

public class tt {

public static void main(String[] args) {


Account acc=new Account(944840,"Maaz bin
Rashid",20000);

acc.abc(acc);

You might also like