whats the error in the method call in this switch block?

import java.util.Scanner;
class bank{
    public void termDeposit(){
        int principle;
        double rate,years;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter Principle Amount : ");
        principle = sc.nextInt();
        System.out.print("Enter rate od interest : ");
        rate = sc.nextDouble();
        System.out.print("Enter time period in years : ");
        years = sc.nextDouble();
        double maturityAmount = (principle*(Math.pow(1+(rate/100),years)));
        System.out.println("Maturity Amount after " +years+ " years is : "+maturityAmount);
    }
    public void reccuringDeposit(){
        int monthlyInstallmentPayment,months;
        double rate;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter Monthly payment : ");
        monthlyInstallmentPayment=sc.nextInt();
        System.out.print("Enter Number of months : ");
        months=sc.nextInt();
        System.out.print("Enter rate of interest : ");
        rate=sc.nextDouble();
        double maturityAmount = ((monthlyInstallmentPayment*months)+(monthlyInstallmentPayment*(months*((months+1)/100)))*(rate/100)*(1/12));
        System.out.println("Maturity Amount after " +months+ " months is : " +maturityAmount);
    }
}
public class Bank{
    public static void main(String[]args){
        System.out.println("Press 1 : Term Deposit. ");
        System.out.println("Press 2 : Reccuring Deposit. ");
        Scanner sc=new Scanner(System.in);
        int ch=sc.nextInt();
        switch(ch){
            case 1:
                Bank obj=new Bank();
                obj.termDeposit();
                break;

            case 2:
                Bank obj1=new Bank();`
                obj1.reccuringDeposit();
                break;

            default :
                System.out.println("WRONG CHOISE");
        }
    }
}

Scanner not passing control to the keyboard

Hi all,
I'm having some issues with the Scanner not waiting for input from the keyboard.
The first method processChoice takes the userChoice and the idea is that in the switch statement there is a call to a method getUserInputForProcessing that takes the action and there scanner takes an input but it's not passing the control to the keyboard,
it goes directly to the Exception because nextLine is empty, not entirely sure why. Is that because it's inside a switch statement?

public void processChoice(int userChoice, BookManager bookManager) {
        switch(userChoice) {
            case 0:
                System.out.println("Goodbye.");
                System.exit(0);
                break;
            case 1:
                System.out.println("You chose READ");
                getUserInputForProcessing("READ");
                bookManager.read();
                break;
            case 2:
                System.out.println("You chose CREATE");
                bookManager.create();
                break;
            case 3:
                System.out.println("You chose UPDATE");
                bookManager.update();
                break;
            case 4:
                System.out.println("You chose DELETE");
                getUserInputForProcessing("DELETE");

                bookManager.delete();
                break;

        }

    }

    public  String getUserInputForProcessing(String action)
    {

        Scanner scanner = new Scanner(System.in);
        System.out.printf("You chose %s: ", action);
        String nextLine = "";

        if(action.equals(READ) || action.equals(DELETE) )
        {
            System.out.println("Enter the searching criterion");
        }
        try
        {
            nextLine = scanner.nextLine();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

        scanner.close();
        return nextLine;
    }

Java question count by any number

I am trying to get a program to work that asks for a user input to count by that number and display 10 numbers per line. I can not get it to display 10 numbers per line. If anyone can explain to me what I am doing wrong?

public static void main(String[] args) 
{
      //final int START = 5;
      final int STOP = 500;
      int NUMBER_PER_LINE = 10;

      Scanner val = new Scanner(System.in);
      System.out.println("Enter your value ");
      int START =val.nextInt();

      for(int i = START; i <= STOP; i +=START)    
      {
          System.out.print(i + "  ");
          if(i % NUMBER_PER_LINE == 0)
             System.out.println();
      val.close();

          }
}

Java “Argot” Translator Help

Hello. As a personal project, I am trying to create a "Java Argot" translator. However I am having some issues.
The purpose of the program is to translate a sentece into the following "Secret Languages": "Pig Latin", "Leet" and "Morse Code". I have only done the "Pig Latin" translator however, everytime I try to activate case one in the "switch case" I get the error message "Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0".

The program shows that the line of code that is sending this message is these two lines: "PigLatin_Translator.main(word);" in the "Translator Menu" and "if(word[count].charAt(0) == 'a' || word[count].charAt(0) == 'e' || word[count].charAt(0) == 'i' || word[count].charAt(0) == 'o' || word[count].charAt(0) == 'u')" in the "PigLatin_Translator". I don't know why the system has an "Index Out of Bounds" error when the program does not give the user a chance to type in a string of code (if it allowed the user to type in a string of code then it would have an index). Please Help. Thank You.

Main Menu for Translator Code (some parts of code are removed since no translator is available yet for the other switch cases

        Scanner scan = new Scanner (System.in);

        System.out.println("****Welcome to the \"Argot \" translator. A translator that translates some common and un-common forms of \"Secret Language\"**** ");
        System.out.println("|Look below at the menu to naviage to which translator you would like to use...");
        System.out.println("|Translator Name                  |        Transator Number|");
        System.out.println("|The \"PigLatin\" Translator        |        Press \"1\" on your keyboard to activate|");
        System.out.println("|\"The \"Morse Code\" Translator     |        Press \"2\" on your keyboard to activate [Comming Soon]|");
        System.out.println("|\"The \"Leet\" Translator           |        Press \"3\" on your keyboard to activate [Comming Soon]|");
        int option = scan.nextInt();

        //Switch case that navigates though translator options
        switch(option){

        case 1:
            //Asks user to type in a sentence for the translator
            System.out.print("Type in a word so it can be translated into \"Pig Latin \": ");
            String wordTyped = scan.nextLine(); 

            //Sends the letter to all Lowercase
            String wordLowercae = wordTyped.toLowerCase();

            //Separates string of words into different words
            String[] word = wordLowercae.split(" "); 

            PigLatin_Translator.main(word);

            System.out.println();

            //Tells the user the "PigLatin Translation
            System.out.print("Here is the \"Pig Latin \" translation: ");

Pig_Latin Translator Code

    public static void main(String[] word) {

    Scanner scan = new Scanner (System.in);

    //Loop that controls the separated words
    for (int count = 0; count < word.length; count++ ) {

        //Pig Latin Rule for "Vowels" (excluding "Y")
        if(word[count].charAt(0) == 'a' || word[count].charAt(0) == 'e' || word[count].charAt(0) == 'i' 
                || word[count].charAt(0) == 'o' || word[count].charAt(0) == 'u') {

            String newWord = word[count] + "-yay";
            System.out.print(" " + newWord);

        }

Palindrome Checker

Hi guys so I was playing with some code which would determine the whether a string is a palindrome or not. Its been a mixed bag of results with some palindromes being detected while others aren't. I do apologize to the lack of polish of my comments but I hope that someone might be able to see where the error is and give me good feedback. I think the error is in the set of code that removes the special characters from the string.
As a reference, I am using this webiste: http://www.palindromelist.net/ as the source for the palindrome strings. However the really long ones have resulted in errors.

package palindrome;
/* 
 * Author: venom 
 * Last Edit Date: 2/15/2019
 * This program will check whether a string is a palindrome
 * JDK 11
 */

import java.util.Scanner; // Scanner class used to collect user input of various strings
import javax.swing.JOptionPane; // Will be used to build the GUI for the palindrome test

public class Palindrome {

    public static void main(String[] args) {
        palindrome();
    }

public static void palindrome(){
        //Create the a scanner object to collect user input However will be re-enabled at the end
        Scanner sc = new Scanner(System.in);

        //System.out.print();
        //Variable to store the user string
        String input = null;
        do {
       input = JOptionPane.showInputDialog(null,"Welcome to the Palindrome Test App.\n" + 
                                                    "Enter a string to test: ", "Palindrome App", 
                                                    JOptionPane.INFORMATION_MESSAGE);
        } while (input.isEmpty() == true);

        input = input.toLowerCase();// set the input to lower case 
        // Here we are removing all special characters from a string
        input = input.replace(" ","").replace("!", "").replace(".", "").replace(",", "").replace("?","")
                .replace("-", "").replace("/", "").replace("\\","").replace("'", "").replace("\"", "").replace(":", "")
                .replace("`", "").replace(";", ""); 

        String message = null;

        //String dummy1 = "Jabroni"; // This is the first dummy palindrome string
        //dummy1 = dummy1.toLowerCase();
       // String dummy2 = ""; // This a non palindrome string

        int strLength = input.length(); // This will count the number of characters in a string
        int midCount = strLength / 2; // The "midCount" is divided into half so that we do not loop all the way

        // Initialize the character variables used to compare the chars in the loop
        char bChar; // Will store to check the beginning character
        char eChar; // Will store to check the ending char

        // Initialize a counter variable which will be used to compare
        //System.out.println(dummy1);

        int cCount = 0; // This will count how many chars are similar
        for (int x = 0; x < midCount; x++)
        {

            strLength--; // Reduces the string by 1
            //System.out.println(strLength);
            bChar = input.charAt(x);
            eChar = input.charAt(strLength);

            // If conditionals for comparison of characters
            if (bChar == eChar){
               cCount += 1;
            } 
        }

        // Compare the midpoint with cCount 
        // If they match then the code is a success if not we have failed
        if (cCount == midCount){
            message = "Success! ;-D The string is a Palindrome";
        }
        else 
            message = "It is not a Palindrome. Sorry :-(";

        JOptionPane.showMessageDialog(null, message, "Palindrome App", JOptionPane.INFORMATION_MESSAGE);
    }     
}

Java – Dice Game help

The entire point of this dice game is for a user to first roll four dice, if the answer to this roll is a 9,11,18 or 24 the user wins. If they roll a 6, 12, 13, 17, 19 or 23 the user loses. But if the user rolls any other number, that number becomes the goal number and they must roll it again to win, otherwise they roll a 13 and lose. I have most of this code established and functioning - the goal number is a little sketchy but more importatnly there is one more part of the code that I don't understand. For the final part of this code it is required that the user type either "1" to play the game manually as is or instead type "2" to let the computer play the game and the user is to input the amount of times for the computer to play, so basically how many times it shoud loop, displaying the results each time. Any help in understanding this would be greatly appreciated, I'm at a loss.

//Created 10/24/18
//Created by 
//Last Edited 11/9/18
//This is a programn used to simulate a dice game where four dice are rolled. If the numbers 9, 11, 18 or 24 are rolled the player wins. If 6, 12, 13, 17, 19 or 23 are rolled the player loses. Any other number rolled becomes the new goal number and must be rolled again in order to win.

import java.util.Scanner;
import java.util.Random;

public class P2A2_Ilovar_4182781{

// This portion of code simulates the rolling of dice.
    static int roll()
{
    int die1 = (int)(Math.random()*6) + 1;

    return die1;
}

static boolean playerWins(int dieSum)// This boolean method returns the values of the winning numbers rolled.
{
     return dieSum == 9 || dieSum == 11 || dieSum == 18 || dieSum == 24;
}

static boolean playerLoses(int dieSum)// This method is the exact same as the one above it, but this method is true when the sum of the dice equals the losing numbers.
   {
       return dieSum == 6 || dieSum == 12 || dieSum == 13 || dieSum == 17 || dieSum == 19 || dieSum == 23; 
}

static boolean playerSets(int dieSum)// This method is the exact same as the ones above it, but this method is true when the sum of the dice equals any of the goal numbers.
{
return dieSum == 22 || dieSum == 21 || dieSum == 20 || dieSum == 16 || dieSum == 15 || dieSum == 14 || dieSum == 10 || dieSum == 8 || dieSum == 7 || dieSum == 5 || dieSum == 4; 
}

public static void main(String[] args){
    Scanner in = new Scanner(System.in);

// Here the code prints out the rules and creator of the game.
System.out.println("Welcome to the CocoPanther Dice Game!");
System.out.println("Created by .");
System.out.println("In this game we will roll 4 dice. If you roll a 9,11,18 or 24 you win. But if you roll a 6, 12, 13, 17, 19 or 23 you lose.");
System.out.println("If you roll any other number that number becomes the new goal and if it is rolled you win. But if you roll an 13, you lose");
// Here the code asks and takes the name of the user.
System.out.println("What is your name?");
String inNext =in.nextLine();
System.out.println("Welcome,"+inNext);

// The code then performs an infinite loop to allow the user to roll the dice as many times as they want.
while(true)
{
    // The values of each die roll is stored here.
    String again = "y";
    int die1 = roll();
    int die2 = roll();
    int die3 = roll();
    int die4 = roll();

    Scanner keyboard = new Scanner(System.in);
    // Each value is then added to give the final number.
    int dieSum = die1 + die2 + die3 + die4;

    System.out.println("You've rolled a " +dieSum);

    // Here the code references the boolean methods from earlier, stating whether the user has won, lost or rolled a goal number.
    // Player wins portion.
   if(playerWins(dieSum))
    {
        System.out.print("Congratulations, you've won!");

    }
    // Player loses portion.
    if(playerLoses(dieSum))
    {
        System.out.println("Sorry, you've lost the game.");

    }
    // Goal number portion.
    if(playerSets(dieSum))
    {
        System.out.println("You've rolled a goal number! Roll it again to win.");

    }
    // This line simply allows the user to roll the dice again.
        System.out.println(" Roll them again (y=yes)? ");
        again = keyboard.nextLine();

    }
}