Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void compare(int, int)
void compare(char, char)
void compare(String, String)
```
4. Program that creates a class Account that stores a variable balance. The class has methods to start account, to deposit money, to withdraw money and tell the current balance amount.
4. Program that creates a class Account that stores a variable balance. The class has methods to start account, to deposit money, to withdraw money and tell the current balance amount. [Temp.java](https://github.com/TEJ-1-8/Java-Programs-1/blob/main/Temp.java)
5. Program to implement a Book class that stores the details of a book such as its code, title and price (Use constructors to initialize the objects).
6. Program to differentiate between static and non-static methods.
7. Program to illustrate the usage of **this**, **final** and **finalize**.
Expand Down
59 changes: 59 additions & 0 deletions Temp.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import java.util.*;
class Temp
{
public static void main(String[] args)
{
Account ob = new Account(); //Defaukt Constructor
ob.Traverse();
}
}

class Account
{
public void Traverse()
{
Scanner sc = new Scanner(System.in);
int i=0,num1,balance=0,flag=-1;
while(i!=1)
{
System.out.println("\n\nEnter 1 to Create Account.\nEnter 2 to Deposit Money.\nEnter 3 to Withdraw Money.\nEnter 4 to Check Account Balance.\nEnter 5 to Exit.");
System.out.print("\nEnter your Choice: ");
num1=sc.nextInt();
if(num1<1 || num1>5)
System.out.println("Invalid Choice!! \nEnter a Valid Input..!!");
else
{
switch(num1)
{
case 1:
if(flag==-1)
{
flag=0;
System.out.println("Account created successfully.");
}
else
System.out.println("Invalid Choice!! \nAccount already successfully...!");
break;
case 2:
System.out.print("\nEnter the amount you want to deposit: ");
int temp=sc.nextInt();
balance+=temp;
break;
case 3:
System.out.print("\nEnter the amount you want to withdraw: ");
int temp2=sc.nextInt();
balance-=temp2;
break;
case 4:
System.out.println("Balance in your account is: "+balance);
break;
case 5:
i=1;
System.out.println("Goodbye!! Have a Nice Day....");
break;
}
}
}
sc.close();
}
}