java

  • Unknown's avatar

    import java.util.*;
    public class Trial{
    private int totalbalance;
    private int withdraw;
    private int deposit;

    public Trial(){
    totalbalance=0;
    withdraw=0;
    int deposit=0;
    }
    public static void main(String args[]){
    Scanner check=new Scanner(System.in);
    Trial c=new Trial();
    String task=””;
    while(true){
    System.out.println(“d-deposit”);
    System.out.println(“w-withdraw”);
    System.out.println(“v-viewAccount”);
    System.out.println(“q-quit”);
    System.out.print(“Select your task:”);
    task=check.next();
    if(task.equals(“d”) || task.equals(“D”))
    c.deposit();
    else if(task.equals(“w”) || task.equals(“W”))
    c.withdraw();
    else if(task.equals(“v”) || task.equals(“V”))
    c.viewAccount();
    else if(task.equals(“q”) || task.equals(“Q”))
    System.exit(0);
    else
    System.out.println(“Unknown command”);
    }
    }
    public void deposit(){
    Scanner check=new Scanner(System.in);
    int deposit=0;
    System.out.println(“Enter your amount”);
    deposit=check.nextInt();
    totalbalance+=deposit;
    System.out.println(“Your Total balance is =” + totalbalance);

    }
    public void withdraw(){
    Scanner check=new Scanner(System.in);
    int withdraw;
    System.out.println(“Enter your amount”);
    withdraw=check.nextInt();
    totalbalance-=withdraw;
    if(totalbalance>=0)
    System.out.println(“Your Total balance is =” + totalbalance);
    else
    totalbalance+=withdraw;
    System.out.println(“You dont have enough money to withdraw.”);
    }
    public void viewAccount(){
    System.out.println(“Your Total balance is =” + totalbalance);
    }
    }

    The blog I need help with is: (visible only to logged in users)

  • Unknown's avatar

    And the question, other than “how do I embed code in a Wp.com blog that WP.com bans” is?

  • The topic ‘java’ is closed to new replies.