Java Hyd Team
746 subscribers
986 photos
39 videos
670 files
690 links
https://teamhydteam.my.canva.site/

Can visit us on our website 😊
Still working on it 😊
Download Telegram
Come in front everyone
[9/23, 11:05] ENTREPRENEUR: public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Bank bank = new Bank();
boolean exitRequested = false;
while(!exitRequested) {
PrintService.printMenu();
int choice = Integer.parseInt(sc.next());
switch (choice) {
case 1:
bank.registerAccount();
break;
case 2:
bank.loginAccount();
break;
case 3:
exitRequested = true;
break;
default:
System.out.println("Wrong input");
break;
}
}
}
[9/23, 11:05] ENTREPRENEUR: public static void printMenu() {
System.out.println("Hello, press: " + "\n" +
"\r" + "1.Register" + "\n" +
"\r" + "2.Log in" + "\n" +
"\r" + "3.Exit");
}

public static void existAccountMenu(){
System.out.println("What would you like to do?" + "\n" +
"\r" + "1.Info" + "\n" +
"\r" + "2.Deposit money" + "\n" +
"\r" + "3.Withdrawal money" + "\n" +
"\r" + "4.Money transferring" + "\n" +
"\r" + "5.Exit");
}
Main.java
[9/23, 11:07] ENTREPRENEUR: private final List<Account> bankAccounts;
private final Scanner sc;

public Bank() {
bankAccounts = new ArrayList<>();
sc = new Scanner(System.in);
}

public Account isAccountExist(int accountID, String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getID() == accountID && account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}

//overload method -
public Account isAccountExist(String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}

public void registerAccount() {
System.out.println("First name?");
String firstName = sc.next();
System.out.println("Last name?");
String lastName = sc.next();
System.out.println("Phone number?");
String phoneNumber = sc.next();
if (isPhoneNumberCorrect(phoneNumber)) {
bankAccounts.add(new Account(firstName, lastName, phoneNumber));
System.out.println("You have created account successfully!" + "\n" +
"Your account ID is: " + bankAccounts.get(bankAccounts.size() - 1).getID());

}
}

public void loginAccount() {
System.out.println("Please enter your ID:");
int accountID = sc.nextInt();
System.out.println("Please enter your phone number:");
String phoneNumber = sc.next();
if (isPhoneNumberCorrect(phoneNumber)) {
Account selectedAccount = isAccountExist(accountID, phoneNumber);
boolean exitRequested = false;
while (!exitRequested) {
PrintService.existAccountMenu();
int choice = Integer.parseInt(sc.next());
switch (choice) {
case 1:
System.out.println(selectedAccount.toString());
break;
case 2:
System.out.println("Please enter deposit amount:");
double depositAmount = sc.nextDouble();
selectedAccount.depositMoney(depositAmount);
break;
case 3:
System.out.println("Please enter withdrawal amount:");
double withdrawalAmount = sc.nextDouble();
selectedAccount.withdrawal(withdrawalAmount);
break;
case 4:
System.out.println("Please enter the phone number of the account you want to transfer to: ");
String accountPhoneNumber = sc.next();
if (isPhoneNumberCorrect(accountPhoneNumber)) {
Account accountToTransfer = isAccountExist(accountPhoneNumber);
System.out.println("Enter the amount of money you would like to transfer:");
double moneyToTransfer = sc.nextDouble();
selectedAccount.moneyTransfer(selectedAccount, accountToTransfer, moneyToTransfer);
break;
}
case 5:
exitRequested = true;
break;
default:
System.out.println("Wrong input");
break;
}
}
}
}

public static boolean isPhoneNumberCorrect(String phoneNumber){
if(phoneNumber.length() != 10){
System.out.println("Phone number must be 10 digits.");
return false;

} else {
return true;
}
}
PrintService.java
public static void printMenu() {
System.out.println("Hello, press: " + "\n" +
"\r" + "1.Register" + "\n" +
"\r" + "2.Log in" + "\n" +
"\r" + "3.Exit");
}

public static void existAccountMenu(){
System.out.println("What would you like to do?" + "\n" +
"\r" + "1.Info" + "\n" +
"\r" + "2.Deposit money" + "\n" +
"\r" + "3.Withdrawal money" + "\n" +
"\r" + "4.Money transferring" + "\n" +
"\r" + "5.Exit");
}
Main.java
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Bank bank = new Bank();
boolean exitRequested = false;
while(!exitRequested) {
PrintService.printMenu();
int choice = Integer.parseInt(sc.next());
switch (choice) {
case 1:
bank.registerAccount();
break;
case 2:
bank.loginAccount();
break;
case 3:
exitRequested = true;
break;
default:
System.out.println("Wrong input");
break;
}
}
}
[9/23, 11:09] ENTREPRENEUR: private final String firstName;
private final String lastName;
private double balance;
private static int uid = 0;
private final String phoneNumber;
private final int id;


public Account(String firstName, String lastName, String phoneNumber){
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.balance = 0.0;
uid++;
this.id = uid;
}

public String getFirstName(){
return this.firstName + "";
}
public String getLastName(){
return this.lastName + "";
}
public double getBalance(){
return this.balance;
}
public void setBalance(double newBalance) {
this.balance = newBalance;
}
public int getID(){
return this.id;
}
public String getPhoneNumber(){
return this.phoneNumber + "";
}

public void depositMoney(double depositAmount){
this.balance += depositAmount;
System.out.println("You have deposit " +depositAmount +" to your account." + "\n" +
"Balance is now: " +this.balance);
}

public void withdrawal(double withdrawalAmount){
if(this.balance < withdrawalAmount) {
System.out.println("You don't have enough funds.");
} else {
this.balance -= withdrawalAmount;
System.out.println("You have withdrawal " +withdrawalAmount + " from your account." + "\n" +
"Balance is now: " +this.balance);
}
}

public void moneyTransfer(Account thisAccount, Account toAccount, double amountToTransfer){
if(thisAccount.getBalance() > 0) {
toAccount.setBalance(toAccount.balance += amountToTransfer);
thisAccount.setBalance(this.balance -= amountToTransfer);
} else {
System.out.println("You don't have enough funds");
}
}
@Override
public String toString(){
return "Name: " + getFirstName() + "\n" +
"Last name: " +getLastName() +"\n" +
"Balance: " + getBalance() + "\n" +
"ID: " + getID();
}
Bank.java
private final List<Account> bankAccounts;
private final Scanner sc;

public Bank() {
bankAccounts = new ArrayList<>();
sc = new Scanner(System.in);
}

public Account isAccountExist(int accountID, String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getID() == accountID && account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}

//overload method -
public Account isAccountExist(String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}
private final String firstName;
private final String lastName;
private double balance;
private static int uid = 0;
private final String phoneNumber;
private final int id;


public Account(String firstName, String lastName, String phoneNumber){
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.balance = 0.0;
uid++;
this.id = uid;
}

public String getFirstName(){
return this.firstName + "";
}
public String getLastName(){
return this.lastName + "";
}
public double getBalance(){
return this.balance;
}
public void setBalance(double newBalance) {
this.balance = newBalance;
}
public int getID(){
return this.id;
}
public String getPhoneNumber(){
return this.phoneNumber + "";
}

public void depositMoney(double depositAmount){
this.balance += depositAmount;
System.out.println("You have deposit " +depositAmount +" to your account." + "\n" +
"Balance is now: " +this.balance);
}

public void withdrawal(double withdrawalAmount){
if(this.balance < withdrawalAmount) {
System.out.println("You don't have enough funds.");
} else {
this.balance -= withdrawalAmount;
System.out.println("You have withdrawal " +withdrawalAmount + " from your account." + "\n" +
"Balance is now: " +this.balance);
}
}

public void moneyTransfer(Account thisAccount, Account toAccount, double amountToTransfer){
if(thisAccount.getBalance() > 0) {
toAccount.setBalance(toAccount.balance += amountToTransfer);
thisAccount.setBalance(this.balance -= amountToTransfer);
} else {
System.out.println("You don't have enough funds");
}
}

@Override
public String toString(){
return "Name: " + getFirstName() + "\n" +
"Last name: " +getLastName() +"\n" +
"Balance: " + getBalance() + "\n" +
"ID: " + getID();
}
Bank.java
private final List<Account> bankAccounts;
private final Scanner sc;

public Bank() {
bankAccounts = new ArrayList<>();
sc = new Scanner(System.in);
}

public Account isAccountExist(int accountID, String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getID() == accountID && account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}

//overload method -
public Account isAccountExist(String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}
U guy's are in class or lab
// wap to accept 2 numbers in b/w 2 numbers display all the prime numbers ....

import java.util.Scanner;

public class Prime {

public static void main(String[] args) {
Scanner x = new Scanner (System.in);
System.out.println("Enter a range for prime numberz ");
int low = x.nextInt();
int high = x.nextInt();

while (low < high) {
boolean flag = false;

for(int i = 2; i <= low/2; ++i) {
// condition for nonprime number
if(low % i == 0) {
flag = true;
break;
}
}

if (!flag && low != 0 && low != 1)
System.out.print(low + " ");

++low;
}
}
}
private final String firstName;
private final String lastName;
private double balance;
private static int uid = 0;
private final String phoneNumber;
private final int id;


public Account(String firstName, String lastName, String phoneNumber){
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
this.balance = 0.0;
uid++;
this.id = uid;
}

public String getFirstName(){
return this.firstName + "";
}
public String getLastName(){
return this.lastName + "";
}
public double getBalance(){
return this.balance;
}
public void setBalance(double newBalance) {
this.balance = newBalance;
}
public int getID(){
return this.id;
}
public String getPhoneNumber(){
return this.phoneNumber + "";
}

public void depositMoney(double depositAmount){
this.balance += depositAmount;
System.out.println("You have deposit " +depositAmount +" to your account." + "\n" +
"Balance is now: " +this.balance);
}

public void withdrawal(double withdrawalAmount){
if(this.balance < withdrawalAmount) {
System.out.println("You don't have enough funds.");
} else {
this.balance -= withdrawalAmount;
System.out.println("You have withdrawal " +withdrawalAmount + " from your account." + "\n" +
"Balance is now: " +this.balance);
}
}

public void moneyTransfer(Account thisAccount, Account toAccount, double amountToTransfer){
if(thisAccount.getBalance() > 0) {
toAccount.setBalance(toAccount.balance += amountToTransfer);
thisAccount.setBalance(this.balance -= amountToTransfer);
} else {
System.out.println("You don't have enough funds");
}
}

@Override
public String toString(){
return "Name: " + getFirstName() + "\n" +
"Last name: " +getLastName() +"\n" +
"Balance: " + getBalance() + "\n" +
"ID: " + getID();
}
Bank.java
private final List<Account> bankAccounts;
private final Scanner sc;

public Bank() {
bankAccounts = new ArrayList<>();
sc = new Scanner(System.in);
}

public Account isAccountExist(int accountID, String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getID() == accountID && account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}

//overload method -
public Account isAccountExist(String phoneNumber) {
for (Account account : bankAccounts) {
if (account.getPhoneNumber().equals(phoneNumber)) {
return account;
}
}
System.out.println("One of the details is incorrect");
return null;
}public class Main{
public static void main(String[]args)
{
int[] ids = {10,20,30};
String[] names = {"aman", "rash" ,"anand"};
double [] salaries = {2000,5000,70000};
List<Emp> list=new Arraylist<Emp>();

for(int i= 0; i<=ids.length-1;i++){
Emp e = new Emp(ids[i] , names [i], salaries [i]);
for(Emp e :list){
System.out.println(e.id + e.names + e.salaries);
}
}

}
}
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class EmployeeManagement {

public static void main(String[] args) {

List<Employee> list = new ArrayList<>();
list.add(new Employee(101, "Omraj", 25, "Male", "IT", 2022, 120000.00));
list.add(new Employee(105, "Swati", 30, "Female", "IT", 2000, 190000.00));
list.add(new Employee(108, "Pankaj", 22, "Male", "COMP", 2020, 180000.00));
list.add(new Employee(109, "Raju", 30, "Male", "Finance", 2021, 560000.00));
list.add(new Employee(102, "Ganesh", 32, "Male", "Product", 1999, 590000.00));
list.add(new Employee(103, "Alon", 66, "Male", "COMP", 1991, 900000.00));
list.add(new Employee(115, "Sanvi", 25, "Female", "Account", 2000, 780000.00));
list.add(new Employee(111, "Dipti", 25, "Female", "Account", 1998, 880000.00));
list.add(new Employee(112, "Jeff", 25, "Male", "Account", 2000, 450000.00));

System.out.println("Print the name of all the department?");
list.stream().map(Employee::getDepartment).distinct().forEach(System.out::println);
System.out.println("--------------------------------------------");

System.out.println("How many Employee Present in the org");
Long count = list.stream().map(Employee::getName).count();
System.out.println(count);
System.out.println("--------------------------------------------");

System.out.println("What is the average age of male and female employee");
Map<String, Double> averagingAge = list.stream()
.collect(Collectors.groupingBy(Employee::getGender, Collectors.averagingInt(Employee::getAge)));
System.out.println(averagingAge);

System.out.println("How many employee Present in each department");
Map<String, Long> map = list.stream()
.collect(Collectors.groupingBy(Employee::getDepartment, Collectors.counting()));
System.out.println(map);
System.out.println("Average Salary of Each department");
Map<String, Double> collect = list.stream().collect(
Collectors.groupingBy(Employee::getDepartment, Collectors.averagingDouble(Employee::getSalary)));
System.out.println(collect);

System.out.println("How many male and female empl in Account");
Map<String, Long> collect3 = list.stream()
.filter(e -> e.getDepartment().equals("Account") || e.getDepartment().equals("IT"))
.collect(Collectors.groupingBy(Employee::getGender, Collectors.counting()));
System.out.println(collect3);

list.stream().filter(e -> e.getId() == 101).map(Employee::getSalary).forEach(System.out::println);
}
}
public class Employee {
int id;
String name;
int age;
String gender;
String department;
int yearOfJoining;
double salary;
public Employee(int id, String name, int age, String gender, String department, int yearOfJoining, double salary) {
super();
this.id = id;
this.name = name;
this.age = age;
this.gender = gender;
this.department = department;
this.yearOfJoining = yearOfJoining;
this.salary = salary;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getDepartment() {
return department;
}
public void setDepartment(String department) {
this.department = department;
}
public int getYearOfJoining() {
return yearOfJoining;
}
public void setYearOfJoining(int yearOfJoining) {
this.yearOfJoining = yearOfJoining;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
@Override
public String toString() {
return "Employee [id=" + id + ", name=" + name + ", age=" + age + ", gender=" + gender + ", department="
+ department + ", yearOfJoining=" + yearOfJoining + ", salary=" + salary + "]";
}
}
Write down code in 2 classes
Use above code for reference only
WAP to create an employee management application using Arraylist, map and store the data ...
https://t.me/Freelearningjavafullstack

Anyone can join this group for learning process
Complete this application today


For sure if any issues ping @stockkida
If completed message fast
<!DOCTYPE html>
<html>
<head>


<title>LOGIN FORM</title>
</head>
<body>

<h1>Login form</h1>
<form action="#" method="post"></form>
<p>User name</p>
<input type="text" name="uname" placeholder="User name">
<p>Password</p>
<input type="password" name="pwd" placeholder="password">
<a href=""><button>LOGIN</button></a>



</script>

</body>
</html>
<!DOCTYPE html>
<html>
<head>

</head>
<body>
<table border="1px">
<tr>
<th><a href="p2.html">HOME</a></th>
<th><a href="p4.html">ABOUT US</a></th>
<th><a href="p5.html">REGISTRATION</a></th>
<th><a href="p6.html">LOGIN</a></th>
<th><a href="p7.html">CONTACT</a></th>
</tr>
</table>
</body>
</html>