Announcement

Collapse
No announcement yet.

SavingsAccount + Print and Static Create Object

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SavingsAccount + Print and Static Create Object

    class SavingsAccount
    PHP Code:
    package bank;


    import java.io.PrintStream;
    import java.util.Scanner;

    public class 
    SavingsAccount {


        
    ////////////// constructor
        
    public SavingsAccount (double in_saldodouble in_interest){
               
    saldo in_saldo;
               
    interest in_interest;

        }

         public 
    void deposit double in_deposit){
              
    saldo+=in_deposit;

         }
         public 
    void withdraw double in_withdraw ){
               
    saldo-=in_withdraw;

         }
         public 
    double get_balance ( ){
                return 
    saldo;

         }

        
    /////////////   aggiungi interesse trimestrale al conto
         
    public void addInterest () {
             
    saldo += (((saldo 100) * interest)/4);

         }


        public static 
    SavingsAccount create_object Scanner stream){
               
    double saldo stream.nextDouble();
               
    double interesse stream.nextDouble();
               return new 
    SavingsAccount(saldo,interesse);

        }


        public 
    void print ( PrintStream stream){
              
    stream.println (saldo);
              
    stream.println (interest);

        }

    private 
    double saldo;
    private 
    double interest;


    main
    PHP Code:
    import bank.SavingsAccount;

    import java.util.Scanner;

    /**
     * Created with xgiovio.macbookair.
     * User: xgiovio
     * Date: 23/09/13
     * Time: 14:57
     */


    public class test {

        public static 
    void main (String [] input_data){


            
    SavingsAccount obj SavingsAccount.create_object( new Scanner(System.in));
            
    obj.print(System.out);

        }

    | VFX Artist, C++ Programmer, HW Overclocker | Web: xgiovio.com Email: xgiovio@gmail.com Twitter: @xgiovio
Working...
X

Google Profile


My name is Giovanni Di Grezia, but people call me xgiovio.

Here is my homepage:.

I'm a VFX Artist and Software Developer.

Giovanni Di Grezia