JAVA - I am asking for the user to input their firstName andlastName but I want the method myMethod() to be able to print itwhen it is called. Is that possible? I'm new to Java and i'm nottoo sure what I should do to fix this. Also if I were to create aIF statement would I have to declare int amountDeposited; , intaccountBalance; , int newBalance; in the new if statement.
import java.util.Scanner;
import java.util.Arrays;
import java.time.LocalDate;
public class UserData {
  static void myMethod(){
  Scanner input = new Scanner(System.in);
  System.out.println(\"Amount you want to deposit :\");
  int amountDeposited = input.nextInt();
  int accountBalance = 0;
  int newBalance = accountBalance +amountDeposited;
  input.nextLine();
  System.out.println(\"DO you wish you print out youraccount information? Yes or No?\");
  String outputInfo = input.nextLine();
  if (outputInfo.equals(\"yes\")){
  System.out.println(\"Name: \" + firstName + \" \" +lastName + \" \n Account TYpe: \" + accountType + \" \n AccountNumber: \" +accountNumber + \" \n Balance : \" + newBalance);
}
  if(outputInfo.equals(\"no\")){
  System.out.println(\"Ok! Have a nice day!Goodbye!\");
}
  }
  public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println(\"Bank Menu\");
System.out.println(\"Enter your account number : \");
int accountNumber = input.nextInt();
LocalDate myObj = LocalDate.now(); // Create a date object
System.out.println(\"Date: \" + myObj); // Display the currentdate
//makes sure the next line isnt skipped
input.nextLine();
//Asking user for first and last name
System.out.println(\"Enter your first name: \");
String firstName = input.nextLine();
System.out.println(\"Enter your last name: \");
String lastName = input.nextLine();
// Asking for account number, account type, todays date
System.out.println(\"Enter your account type savings or checking :\");
String accountType = input.nextLine();
//Type of transaction
System.out.println(\"What type of transaction: Deposit , Withdraw,Cash Check, Account Balance : \");
String transactionType = input.nextLine();
//Deposit
if (transactionType.equals(\"deposit\") ||
transactionType.equals(\"Deposit\")){
int amountDeposited;
int accountBalance;
int newBalance;
myMethod();
}