Guest User

Bankovy_ucet1

a guest
Oct 23rd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. import java.util.*;
  2.  
  3.  
  4. public abstract class AplikaciaSekvencna{
  5.    
  6.   public static void main(String[] args){
  7.       Scanner klav = new Scanner(System.in);
  8.      
  9.       BankovyUcet bu;
  10.       String vstNU;        //vstup nazov uctu
  11.       int vstPS;           //vstup pociatocny stav
  12.       int vstVKLD;
  13.       int porCisVkl=0;
  14.       int porCisVyb=0;
  15.       String vyslAkcie;
  16.      
  17.       System.out.println("\f zaciatok programu");
  18.      
  19.       System.out.print("Zadaj nazov uctu");
  20.       vstNU=klav.nextLine();
  21.      
  22.       System.out.print("Zadaj pociatocny stav uctu");
  23.       vstPS=klav.nextInt();
  24.      
  25.       bu= new BankovyUcet(vstNU,vstPS);
  26.       System.out.println(bu);
  27.      
  28.       porCisVkl++;
  29.       System.out.printf("Zadaj %d . vklad : ",porCisVkl );
  30.       vstVKLD= klav.nextInt();
  31.      
  32.       vyslAkcie= bu.vlozPeniaze(vstVKLD);
  33.       System.out.println(vyslAkcie);
  34.       System.out.println(bu);
  35.      
  36.      
  37.       System.out.println("koniec programu");
  38.     }
  39. }
  40.  
  41. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
  42.  
  43. public class BankovyUcet{
  44.    
  45.   private String nazovUctu;
  46.   private double stavNaUcte;
  47.  
  48.   public BankovyUcet(String nazovUctu,double pociatocnyStavUctu){
  49.       this.nazovUctu=nazovUctu;
  50.       this.stavNaUcte=pociatocnyStavUctu;
  51.     }
  52.  
  53.   public BankovyUcet(String nazovUctu){
  54.       this(nazovUctu, 10);
  55.     }
  56.    
  57.   public BankovyUcet(){
  58.      this("chudobny student");
  59.     }
  60.    
  61.   public String toString(){
  62.        return String.format(" [ Ucet : nazov = %s, stav = %8.2f] ",nazovUctu,stavNaUcte );
  63.    
  64.     }
  65.  
  66.   public String vlozPeniaze( int vklad){
  67.       String vysl;
  68.      
  69.       stavNaUcte=stavNaUcte+vklad;
  70.       vysl="Vklad prebehol uspesne";
  71.       return vysl;
  72.     }
  73.    
  74.   public String vyberPeniaze( int vyber){
  75.       String vysl;
  76.      
  77.       stavNaUcte=stavNaUcte-vyber;
  78.       vysl="Vyber prebehol uspesne";
  79.       return vysl;
  80.     }
  81. }
Add Comment
Please, Sign In to add comment