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");
        }
    }
}
Faheem_1 commented: http://www.enews.pk/the-weather-will-be-hot-and-dry-in-most-parts-of-the-country-today/ +0
Re: whats the error in the method call in this switch block? 80 80

Tried putting it ilike: case '1': then curly brackets after : and after the break statement? Also default:{ sentence...}
I'm just a newbie so I'm not sure

Re: whats the error in the method call in this switch block? 80 80

You have a single quote at the end of line 43.

For the corect syntax of a switch, with examples, see the Oracle tutorial page here

ps: You keep creating new instances of Scanner. That can cause problems with text buffers getting lost. Just create one instance when the program starts, and use that for everything.

Re: whats the error in the method call in this switch block? 80 80
1. There is a stray apostrphe at the end of line 43.
2. I changed public class Bank -> public class Main
3. I moved public class Main to the top starting from line 2
4. In the switch statement you try to instantiate a new instance of "Bank" instead of "bank"
    on lines 38 and 42

After correcting these the code compiles and runs.

Re: whats the error in the method call in this switch block? 80 80
  1. The class bank is bad defined, u need follow the code conventions; when u define a class write the first letter in Uppercase, for example Bank. If u need test the method, can define the method main inside of the class Bank.
  2. u have an special character in this code at the end of line 43 (maybe is an copy error)
    Regards.
Re: whats the error in the method call in this switch block? 80 80

Thanks for all the help, fixed some newbie error now its doing good!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.