Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Creation of methods

Have Programming Question? Ask it here!
 
 
 


vinay krrishna
Creation of methods
0 Answer(s)      a year ago
Posted in : Java Beginners


I have a only single class and its having only one method ie., main method only.... i need to develop another method that is to reduce my switching code

package org.bankPackage.one;

import java.util.Scanner; import java.lang.String;;

public class BankClass {

public static void main(String[] args) {

    String[] names={"sandeep","deepthi","srinivas","vinay"};
    String[] nums={"inc0001","inc0002","inc0003","inc0004"};
    int deposite=0,withdral=0,total=0,sub=0,req=0;
    int initial=500;
    String name="",num="",user="",dob="",mail="",mobi="";
    Scanner input =new Scanner(System.in);


    System.out.println("WELCOME TO INCRESOL BANK");
    System.out.println("");
    System.out.println("Enter your Request");
    System.out.println("\n1.Existing User\n2.New User");
    System.out.println("Enter your Request");
    String request=input.next();
    int reqst=Integer.parseInt(request);

    if (reqst==1)
    {

    System.out.print("User Name:");
    name=input.next();
    System.out.print("Account No:");
    num=input.next();

    if (((names[0].equals(name))&&(nums[0].equals(num)))||((names[1].equals(name))&&(nums[1].equals(num)))||((names[2].equals(name))&&(nums[2].equals(num)))||((names[3].equals(name))&&(nums[3].equals(num))))

    {

    System.out.println("");
    System.out.println("Your INCRESOL BANK ACCOUNT Details are");
    System.out.println("");

    System.out.println("A/c Holder Name:"+name);
    System.out.println("A/c Number:"+num);
    System.out.println("");

    System.out.println("Select any one of the following options");
    System.out.println("\n1.Available Balance\n2.Deposite\n3.Withdrawal\n4.Logout");
    System.out.println("Choose your choice :");
    req=input.nextInt();


    while(req<5)
    {           
        switch(req)
        {
            case 1: 

                System.out.println("");
                System.out.println("Your INCRESOL BANK ACCOUNT Details are");
                System.out.println("");

                System.out.println("A/c Holder Name:"+name);
                System.out.println("A/c Number:"+num);
                System.out.println("");

                System.out.println("Your Account Available Balance is:"+initial);

                System.out.println("\nSelect any one of the following options");
                System.out.println("\n1.Available Balance\n2.Deposite\n3.Withdrawal\n4.Logout");
                System.out.println("Choose your choice :");
                req=input.nextInt();
                break;

            case 2:

                System.out.println("");

                System.out.print("Enter Deposite Ammount:");
                deposite=input.nextInt();
                total=initial;
                total=initial+deposite;
                System.out.println("");
                System.out.println("After Deposite Current Ammount is:"+total);
                initial=total;
                System.out.println("\nSelect any one of the following options");
                System.out.println("\n1.Available Balance\n2.Deposite\n3.Withdrawal\n4.Logout");
                System.out.println("Choose your choice :");
                req=input.nextInt();
                break;

            case 3:

                System.out.println("");

                System.out.println("Enter Withdrawal Amount:");
                withdral=input.nextInt();
                sub=initial;
                sub=initial-withdral;
                initial=sub;
                System.out.println("");         
                System.out.println("After Withdrawal Current Ammount is :"+sub);

                System.out.println("\nSelect any one of the following options");
                System.out.println("\n1.Available Balance\n2.Deposite:\n3.Withdrawal:\n4.Logout");
                System.out.println("Choose your choice :");
                req=input.nextInt();
                break;

            case 4:

                System.out.println("your successfully Logged out");
            System.exit(req);
                break;

        } 

    }
}       
else
            System.out.println("\nYou enter wrong login details\nplease enter username and accountnumber\ndetails correctly");          
            input.close();

}   
else
    System.out.println("Please Enter Your Details Following Carefuuly");
    System.out.println("User Name:");
    user=input.next();
    System.out.println("Date of Birth:");
    dob=input.next();
    System.out.println("Mobile Number:");
    mobi=input.next();
    System.out.println("Email Id:");
    mail=input.next();

    System.out.println("Your detials are:\n"+user+"\n"+dob+"\n"+mobi+"\n"+mail);
    System.out.println("If you enter anything wrong u need to Re-Run");

} }


Advertisement
View Answers

Related Tutorials/Questions & Answers:
Creation of methods
Creation of methods  I have a only single class and its having only one method ie., main method only.... i need to develop another method that is to reduce my switching code package org.bankPackage.one; import java.util.Scanner
methods
methods  PrintStream class has two formatting methods,what
Advertisements
methods
methods  PrintStream class has two formatting methods,what
methods
methods  PrintStream class has two formatting methods,what
Creation of xml
Creation of xml  Hi, I need to fetch details from my database and to create a xml file containing all those datas...My database datas are in key value pair... AppID Label Value 12345 Applicant name XXXX 12345 Masterno
How to: generic array creation
How to: generic array creation  How to: generic array creation
object creation - Subversion
object creation in Java  In how many ways we can create objects in Java
object creation - Java Beginners
object creation  I need object creation in depth(with stack,pc registers).Any one can provide me if possible with video/audio
Methods of HttpServlet
Methods of HttpServlet  What are methods of HttpServlet
creation of installer - Java Magazine
creation of installer  plz tell me how can be create installer for any developed application in java?  visit the following url izpack.org.. it will helps u
exe file creation - JDBC
exe file creation   hi i have done a project in java swings.project name is format migrator.means db migrator. now my aim is create EXE FILE for my project. pls do consider
creation of database - SQL
creation of database  hi, where to and how to execute SQL queries?   Hi nanju mysql>CREATE DATABASE search; mysql> SHOW DATABASES; mysql> USE search mysql>create table Emp (fname VARCHAR(20
xml file creation in java
xml file creation in java  how to create xml file in java so that input should not be given from keyboard. and that file should be stored.   Please visit the following links: http://www.roseindia.net/tutorial/java/xml
XSD Creation. - WebSevices
XSD Creation.  When I try to generate xsd from java object. It is generating XSD file finely. But the problem is it isgenerating XSD file elements in alphabetical order. can u please sujest me how can we do that one. I tried
creation of a form - JSP-Servlet
creation of a form  how to create a question paper using JSP code  Hi Friend, We have taken radiobuttons in our application, you can take textarea, textfield etc. Create a table ans(ques,op1,op2,op3,op4,op5,ans
Random Creation of password
Random Creation of password  Dear Sir I have created a form with some details in it.When clicking on the submit button it gives me a password .....Details and the password is saved in the database....The password has
Session creation and tracking
Session creation and tracking  1.Implement the information persistence across servlet destroy or servlet container start/stop. Write a servlet such that when it is stopped (either by container shutdown or servlet stop
creation button using objective c
creation button using objective c  creation button using objective c
bean creation exception
bean creation exception  hi i am getting exception while running simple spring ioc program Exception in thread "main" org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class
xml creation in java
xml creation in java  HI, I need a java program to create an xml file... therez a tutorial in your site to create an xml file at http://www.roseindia.net/xml/dom/CreatXMLFile.shtml but this isn't creating a file, its just
static methods
static methods  why static methods cannot read or write the instance variables
Agile methods
Agile methods   Why use Agile methods?   This methods focus on shorter iterations, in which the software is brought to a releasable level of quality fairly often, usually somewhere between weekly and monthly. Short
Chatbox creation problem
Chatbox creation problem  i have one chat box in my web site and i assigned fixed position to that div.that is workin in mozill but it is not working in ie . thank you`print ("<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
creation of table using a Java swing
creation of table using a Java swing  how to create a table dynamically in Java swing
native methods
native methods  what is native methods in java?   A native method is a method that is implemented in a language other than Java. The Java native method is a great way to gain and merge the power of C or C++ programming
forums creation using spring with hibernate?
forums creation using spring with hibernate?  how to write mandatory fields with validations in forms using spring with hibernate? give me detailed example
PDF creation in JAVA - JSP-Servlet
PDF creation in JAVA  HI! Good morning.... I want to create pdf file and i want to write something into pdf file....before creation. Upto creation i have done but how to write data into pdf. File Writer is not working
cache creation in java - Java Beginners
cache creation in java  Hi All, I am planing to create cache in my web application. please send me the some sample code to create cache by using org.apache.oro.utils package. please help me out. Thanks, mln15584
checkbox custom tag creation in jsf
checkbox custom tag creation in jsf  how to create check box custom tags with the following functionality: 1.there must be two checkboxes 2.when the first box is checked it must populate the names of bikes,when the second
creation an dmanipulation of trees - Java Beginners
creation an dmanipulation of trees  Hi guys? pls i want to find out a hind aboout what these terms or phrases means, -To create and manipulate a Binary Search Tree -To use the Java API's Stack in conjunction with other
Limit the Class Object Creation
Limit the Class Object Creation In this section you will learn about how a class object creation can be a restricted to a fix number of times... to restrict the object creation of a class. This is a simple code in Java where I have
Creation of MultiThreads
Creation of Multiple Threads       Like creation of a single thread, You can also create more than one thread (multithreads) in a program using class Thread
dynamic creation of multiple drop-down menus
dynamic creation of multiple drop-down menus  can anybody plz help me in coding for dynamic creation of multiple drop-down menus in a webpage using ajax/js/html/css
Creation of MultiThreads
Creation of MultiThreads       Like creation of a single thread, You can also create more than one thread (multithreads) in a program using class Thread or implementing interface
validate() and reset() methods
validate() and reset() methods   Describe validate() and reset() methods
Various methods of httpservletresponse interface
Various methods of httpservletresponse interface  What are the various methods of httpservletresponse interface
Final Methods - Java Tutorials
methods The final method  can be declare as follows: public final String
Servlet Methods
Servlet Methods In this section we will read about the various methods... methods that are used to initialize a Servlet, handles the request received..., the Servlet methods are called life-cycle methods of Servlet. Following
Intranet Website creation - plz help me
Intranet Website creation - plz help me   hi.. I have assign with the intranet website creation work..right from scratch to end..And honestly I know nothing about it.My domain is totally different .. can anybody pls help me
methods type - Java Beginners
methods type in Java  Give me an example programs of methods types in Java
Cookie methods in jsp
Cookie methods in jsp   Define cookie methods in jsp ?    Cookie methods : clone() getComment() getDomain() getMaxAge() getName() getPath() getSecure() getValue() getSecure() getVersion
java object class methods
java object class methods  What are the methods in Object class?  There are lots of methods in object class. the list of some methods are as- clone equals wait finalize getClass hashCode notify notifyAll
GET and POST methods
GET and POST methods   What are the differences between GET and POST methods in form submitting, give the case where we can use GET and we can use POST methods
Java overloaded methods
Java overloaded methods  Can overloaded methods can also be overridden
factory methods in java?
factory methods in java?  what are factory methods in java?   Hi Friend, Factory methods are static methods that return an instance of the native class like Pattern.compile(), Calendar.getInstance
Core java interview question, object creation.
Core java interview question, object creation.  How can we restrict to create objects for more than five? That means i want only 5 objects, how to restrict to create 6th objects
abstract methods in java
abstract methods in java  what is abstract methods in java.give better examples for understanding   Hi Friend, Please visit the following link: http://www.roseindia.net/java/master-java/abstract-class.shtml Thanks
 

 

 

DMCA.com