Close
Faqja 0 prej 3 FillimFillim 12 FunditFundit
Duke shfaqur rezultatin -19 deri 0 prej 46
  1. #1
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26

    Java - Programe fillestare për mësimin e Java

    Kam per te kthyer kete "class" te henen ne oren 10am me date 4. Po e postoj ketu nqs ndonje do me ndihmonte do isha mirenjohes, Flm

    4) You are asked to design a program that manages a hospital database system containing doctors information. Take the following steps to design this database management program.

    Hint: class ()

    main

    {
    Doctor [] doc = new Doctor [10]

    doc [0] = new Doctor ("Tom," 10000, 20, internal, new hiredate( "Aug", 20, 1990);
    name, salary, visit fee, speciality, hire date

    doc [1] = new Doctor (...


    1) Give options (println) 1)Doctor, find name, find salary
    2) Ask option- user
    3)
    While ( option !=7)
    { do the work for 1-6 options
    if (option ==1)
    {
    ....
    .....
    }
    else if ( option ==2)

    Write a separate class called HospitalSystem that contains the main method. In the main, create an array of ten doctors of your choice. Each doctor has name, hire date, salary, speciality, and office visit fee. Use last name only

    Write the code to interact with the user using a menu. The menu has 7 options as shown below. The menu will keep interacting with the user using a loop, until the user chooses to quit.

    Option 1- If the user chooses this option, then the program will print information about all doctors in the database. Each doctor's information will be printed in one line.

    hint: Option 1
    { Tom, Hire date, 2000, cardiology, 20;
    Mary, Hire date, 2500, pediatrition, 25;


    Option 2- If the user chooses this option, then the program will prompt and read a doctor name from the user. Then it will print information about all doctors with that name. Each doctor's information will be printed in one line. If no doctors exist with given name, then an appropriate message will be printed.

    hint: { Tim, hire date, speciality
    If no Tim; message there is not Tim

    Option 3- If the user chooses this option, then the program will prompt and read a speciality from the user. Then it will print information about all doctors with that speciality. Each doctor's information will be printed in one line. If no doctors exists with given speciality, then an appropriate message will be printed.

    hint: { Ask the user about the speciality
    Mike----Pediatrition
    Mary----Pediatrition

    Option 4- If the user chooses this option, then the program will prompt and read a fee value. Then it will print information about all doctors whose office visit fee is less than or equal to the given fee. Each doctor's information will be printed in one line. If no doctors exist with office visit fee less than the given fee, then an appropriate message will be printed.

    hint; { What amount

    Option 5- If the user chooses this option, then the program will print information about doctor who has the hightest salary.

    hint: { find the docter with the hightest salary and print

    Option 6-If the user chooses this option, then the program will sort the doctors array in ascending order by name, and then print information about all doctors in sorted order. Each doctor's information will be printed in one line. Perform sorting using bubble sort.

    hint: { Adam
    Brian
    Clyde (order by name)

    void bublle sort (int [] P)

    { int len =P.length
    int tmp;

    for (P=0, i < len, i++)
    {
    for (j = P+1; j< len; j++

    if ( P [i] > [j]

    tmp = P [j]
    P[i] =P [j]
    P [j]= tmp
    }
    }

    Option 7- If the user chooses this option, then the program will quit.
    Ndryshuar për herë të fundit nga edspace : 03-10-2004 më 17:44

  2. #2
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Hidh atë sa ke bërë vetë që të të ndihmojmë nga pak. Mos prit që të të shkruaj njeri gjithë kodin.

    Unë doja ta bëja por nuk e di fort mirë sintaksën e Java dhe do më duhet më shumë se 24 orë afat për të mësuar. Megjithatë nqs ti ke filluar kodin, mund të plotësoj disa gjëra. Mundësia tjetër është që ta bëj në C++ dhe pastaj në je i zoti ta përkthesh vetë në Java. Edhe për C++ vajti vonë tani. Herë tjetër shkruaje kërkesën të paktën një javë përpara.
    Edi

  3. #3
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26
    Flm Edspace megjithese ishte faji im sepse e postova pak me vonese, por me pak mundim i dhashe nje zgjidhje. Megjithate te falenderoj per kohen qe morre ta lexoje.

    Tani kam nje program tjeter: Write a program that plays the role of a cash register.
    The program is to work as follows:

    1. Prompt a user for the amount of sale and amount tendered, and
    read those amounts.

    2. a. Compute and display the total change
    b. Compute and display the number of dollar bills, quarters,
    dimes, nickels and cents in the total change.

    /**
    * Purpose: This is a program that plays the role of a cash register. It reads amount
    * of sale and tender then computes and displays the total change and the denominations
    * in dollars, quarters, dimes, nickles and cents.
    *
    * @author (x)
    * @version (9/29/2004)
    */

    import java.util.Scanner;

    public class Project3

    {
    public static void main (String [] args)

    {
    Scanner scan = new Scanner (System.in);
    float amtSale, amtTendered, totChange;
    int pennies, dollars, quarters, dimes, nickles, cents;

    System.out.print ("Enter amount of sale: ");
    amtSale = scan.nextFloat();
    System.out.print ("Enter amount tendered: ");
    amtTendered = scan.nextFloat();
    totChange = amtTendered - amtSale;
    pennies = (int) (totChange * 100);
    dollars = pennies /100;
    pennies = pennies-dollars*100;

    ....

    }

    A SAMPLE EXAMPLE EXECUTION OF THE PROGRAM IS AS FOLLOWS:
    ENTER AMOUNT OF SALE: 8.28
    ENTER AMOUNT TENDERED BY CUSTOMER: 10.00
    TOTAL CHANGE = $1.72
    DOLLARS = 1
    QUARTERS = 2
    DIMES = 2
    NICKELS = 0
    CENTS = 2

  4. #4
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Ketu e ke kodin e plote per llogaritesen.
    Shkarko skedarin e bashkengjitur per formatin e sakte.

    Here tjeter perktheje kerkesen ne shqip qe te kuptojne edhe ata qe kane deshire te te ndihmojne ose mesojne por nuk dine mire gjuhen angleze.

    Per ata qe nuk kuptojne anglisht, kerkesa e programit ishte per nje regjister parash qe mund ta perdoresh ne nje dyqan per te llogaritur numrin e sakte te kusurit sipas monedhave te ndryshme. Ne kete rast, programi perdor monedhat Amerikane.

    1 cent = 1/100 e dollarit
    1 knickel = 5 cent
    1 dime = 10 cent
    1 quarter = 25 cent

    Nqs cmimi i mallrave eshte $1,65 dhe pagesa eshte $2,00, programi do llogarisë kusurin $0,35 dhe do ti tregoje shitesit qe te ktheje mbrapsh nje 25-ce (quarter) dhe nje 10-ce (dime).

    -------------------------------------------------------------------------------
    Te gjitha variablat jane int, pervec totChange qe eshte float.
    Nuk ka ndonje gje te veshtire per tu kuptuar.

    Per aq kohe sa personi nuk shtyp (-1) per te dale nga programi {
    - Kerkojme cmimin (amtSale) nga perdoruesi deri sa marrim nje shume te pakten 1 cent ose personi shtyp -1 per te mbyllur programin. Nqs shkruan -1 e falenderojme qe perdori programin dhe dalim nga perseritja (loop).
    - Kerkojme pagesen (amtTender) nga perdoruesi deri sa shuma te jete me e madhe se shuma e shitjes (amthSale).
    - Qe te dyja shumat i shumezojme me 100 dhe i kthejme ne int qe te kemi numrin e centeve. Nuk perdora int se kompjuteri nuk ka saktesi te plote ne llogarite me numra me presje.
    - Marrim numrin e centeve per kusurin duke zbritur pagesen nga cmimi.
    - Shfaqim kusurin e plote duke e pjestuar numrin e centeve me 100.
    - Pastaj vazhdojme me llogaritjen e dollareve, 25-ceve (quarters), 10-ceve (dimes), 5-ceve (nickels), 1-eve (cents)
    - Shfaqim gjithcka ne ekran
    //vazhdojme perseri ne krye, ose mbyllim programin
    }

    Per shkak te limiteve te variablave int, programi nuk eshte 100% i sakte per pagesat me te medha se 2 milione e 400 mije. Ne realitet asnjeri nuk paguan 2.400.000 por nqs te duhet saktesi per pagesa me te medha, variablat int duhet ti kthesh ne long.

    Kodi:
    import java.util.Scanner;
    
    public class Project3{ 
    
      public static void main (String [] args){
    
        Scanner scan = new Scanner(System.in);
        float totChange = 0;
        int amtSale = 0, amtTendered = 0;
        int pennies = 0, dollars = 0, quarters = 0, dimes = 0, nickels = 0;
        boolean quit = false; 
    
        while( !quit){
          
          amtSale = 0;
          amtTendered = 0;
    
          while( amtSale < 1 && amtSale != -100){
            System.out.print ("Enter amount of sale (-1 to quit): ");
            amtSale = (int) (scan.nextFloat() * 100);
          }
          
          if( amtSale == -100){
            System.out.println ("Thank you for using my program.");
            quit = true;
          }
          else{
    
            while( amtTendered < amtSale ){
              System.out.print ("Enter amount tendered: ");
              amtTendered = (int) (scan.nextFloat() * 100);
            }
            
            pennies = amtTendered - amtSale;
            totChange = (float) pennies / 100;
            System.out.println ("TOTAL CHANGE = " + totChange );
                    
            dollars = (int) ( pennies / 100 );
            pennies = pennies - ( dollars * 100 );
            
            quarters = (int) ( pennies / 25 );
            pennies = pennies - ( quarters * 25 );
            
            dimes = (int) ( pennies / 10 );
            pennies = pennies - ( dimes * 10 );
    
            nickels = (int) ( pennies / 5 );
            pennies = pennies - ( nickels * 5 );
    
            System.out.println ("DOLLARS = " + dollars);
            System.out.println ("QUARTERS = " + quarters);
            System.out.println ("DIMES = " + dimes);
            System.out.println ("NICKELS = " + nickels);
            System.out.println ("CENTS = " + pennies);
          }
        }
      }
    }
    Skedarët e Bashkëngjitur Skedarët e Bashkëngjitur
    Ndryshuar për herë të fundit nga edspace : 04-10-2004 më 18:24
    Edi

  5. #5
    mesova dhe une Java me perpara, por tani e kam harruar ngaqe nuk me hyn ne pune.
    Shpresoj te marresh rezultat pozitiv me kete projekt Michigansi!

  6. #6
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26
    Shume Faleminderit EdSpace, programi nuk kishte asnje sytax errors dhe ishte shume i sakte.
    Tani them se po ja marr pak doren java programin por akoma e ndiej ndihmen tuaj deri sa tia marr doren mire.
    Edhe 6 assignments me kan mbetur deri sa te mbarojme simestrin shpresoj qe te me ndihmoni
    qe t'ia dal me sukses kesaj klase.

    Me respekt


    This assignment has four parts. The first part is about designing an abstract employee classs.
    The second and third part is about designing two specific types of employee class
    by inheritance. The fourth part is about designing a program that manages a employee database
    system containing information about employees.

    1) Design Employee class that represents an employee. Employee is an abstract class since
    it has one or more abstract methods. Employee has two private data members, name and id.
    The name is a string and id is a positive integer.

    Employee has three constructors. The first constructor has no parameter, the second constructor
    has name and id parameters, and the third constructor is copy constructor.

    Employee class has public methods called getName and getId that return the name and the id
    of the employee.

    Employee has equals, toString, and clone methods. The toString method returns a string containing
    private data members.

    Employee has an abstract method called getPay that has no parameter and return type is double.
    This method is intended to return the weekly pay of the employee.

    2) Design HourlyEmployee that extends Employee. HourlyEmployee has two private data members
    of its own, namely hours and rate. Hours is inteer adn rate is double type. Hours
    is number of hours per week and rate is hourly pay.

    HourlyEmployee has three constructors. Decide what they are and write them

    Write appropriate equals, toString, and clone methods for HourlyEmployee. The toString
    method returns a string containing private data members.

    Implement the display method for HourlyEmployee. This method prints HourlyEmployee
    -name-id-hours-rate.

    Implement teh getPay method for HourlyEmployee. Pay is computed as hours*rate.

    3) Design SalariedEmployee that extends Employee. SalariedEmployee has one private
    data member of its own, namely salary. Salary is integer type. Salary represents annual
    pay amount.

    SalariedEmployee has three constructors. Decide what they are and write them.

    Write appropritate equals, toString, and clone methods for SalariedEmployee. The
    toString method returns a string containing private data members.

    Implement the display method for SalariedEmployee. This method prints
    SalariedEmployee-name-id-salary.

    Implement the getPay method for SalariedEmployee. Pay is computed as salary/52.0.

    4) Write a separate class called EmployeeSystem that contains the main method. In the main,
    create an array of ten employees fo your choice. Each employee is either hourly employee
    or salaried employee. Use last name only. Use distinct id number for each employee.
    IF if is an hourly employee use hours and rate values of your choice. If it is a salaried
    employee, use annual salary value of your choice.

    Write the code to interact with the user using a menu. The menu has 7 options as shown below.
    The menu will keep interacting with the user using a loop, until the user chooses
    to quit.

    Option 1) If the user chooses this option, then the program will print information about
    all employees in the database. Each employee's information will be printed in one line
    using display method. THis should be done by calling displayAll method.
    void displayAll (Employee[] employees) {..}

    Option 2) If the user chooses this option, then the program will prompt and read an employee
    id from the user. THen it will print information about the employee with that id.
    Employee's information will be printed in one line using dipslay method. If no employee
    exists with given id, then an appropriate message will be printed. This should be done
    by calling dispalySpecifc method.
    void displaySpecific(Employee[]) {...}

    Option 3) If the user chooses this option, then the program will print information about
    the employee with the highest weekly pay. Employee's information will be printed in one line
    using display method. The highest paid employee should be found by calling highestPaid method.
    Also note that weekly pay of each employee can be determined by getPay method. Also note
    that clone must be used within highestPaid to avoid alias when returning employee object.
    Employee highestPaid(Employee[] employees ) {..}

  7. #7
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Une nuk e di mire sintaksen e Java por ka sintakse te ngjashme me gjuhet e tjera. Duke te ndihmuar ty po mesoj edhe per vete.

    Kerkesat mire ben qe i hedh ne anglisht por bej nje permbledhje edhe ne Shqip per dy arsye:
    - Ka anetare qe dine Java por nuk te ndihmojne dot se nuk e kuptojne se cfare kerkon
    - Ka anetare qe duan te mesojne Java nga detyrat e tua dhe nuk dine gjuhen.

    Une nuk te garantoj qe do jap gjithnje kodin e plote dhe mos shko me mendjen se do ta bej une dhe te presesh deri minuten e fundit per ta dorezuar. Ti mundohu ti besh vete detyrat dhe nqs ke veshtiresi mund te pyesesh.

    Po te shkruash kerkesen ne Shqip dhe te kem kohe, do te ndihmoj.
    Edi

  8. #8
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Michigansi,

    Unë bëra 3 pjesët e para. Kur të bësh ato që thashë më lart, do ta hedh kodin këtu.
    Edi

  9. #9
    Po shikoj se ka shume njerez te interesuar ne programing dhe vendosa te postoj disa komente mbase jane te dobishme per disa qe kerkojne ndihme.

    Kjo eshte e vetmja menyre per tu bere programues i suksesshem. Merr nje liber sidomos ato qe thone: "Reference C++, Paskal, Java.... e shume gjuhe varet se cilen zgjedh ti" dhe vetem shkruaj programe duke u bazuar ne funskonet qe i shikon ne liber. Kjo eshte e vetmja menyre qe te behesh programues i mire. Gjithashtu duhet te kesh deshire per dicka qe ben dhe te jesh i duruar shume. Dicka tjeter eshte te mesosh si te besh "debug" psh. kur nuk te punon programi te dish nga te fillosh ta testosh dhe te gjesh pse nuk punon programi qe sapo shkruan sepse asnje program nuk punon per te paren here. Dicka tjeter qe dua te them eshte cfare do lloj gjuhe te perdoresh mos u bej merak fare vetem kryesorja eshte te jesh i mire shume ne ate lloj gjuhe. Sot per sot rrekomandojne me shume Java por nuk do te thote qe C++, Fortain, Basic, Pascal etj. jane me prapa sepse te gjitha behen "update" c'do vit. Po te dish nje gjuhe i di te gjitha tjerat vetem mund te shpenzosh nje min per te shikuar se si eshte cfare perdoret psh. per te shfaqur ne dritare rezultatin nje thote cout<< e nje tjeter system.out pra eshte vetem fjale te ndryshe por kur ke referencat eshte shume e lehte. Bill Gates psh. shikoje iku ne Harvard University per nje vit dhe e la, kurse tani eshte programuesi me i madh ne bote pa diplome te shkolles se larte fare. Pra programimi nuk ka nevoje per matematike te komplikuar apo per studim, thjeshte ulu para kompjuterit dhe shkruaj programe te ndryshme dhe vete do ta ndiesh veten programues pas ca kohesh.
    Ndryshuar për herë të fundit nga Klajdi03 : 09-10-2004 më 01:19
    o me dy molle moj te godita
    o me vrave o te vrafte pika
    E nuk te rashe per te vrare

  10. #10
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26
    Flm klajdi03

    Shume faleminderit edhe ti edspace por me pak praktik them se po ja marr doren por doja edhe ndonje menyre tjeter se si mund ta mesoj me shpejt...nqs doni te me ndihmoni kuptohet

  11. #11
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26
    Edspace ja me ne fund


    Kjo detyre ka 4 pjese. Pjesa e pare eshte reth nje klase abstrakte employee. Pjesa e 2 dhe e 3 is reth dy lloj klasa specifike me te trasheguar.Pjesa e 4 eshte ka te beje me nje program qe menaxhon nje database employee sistem qe permban informacion reth punetoreve.
    1) Projekto Klasen Employee qe reprezanton nje punetor. Employee eshte nje klase abstrakte sepse ka nje ose me shume metoda abstrakte.
    Employee ka dy anetare private, emri dhe identifikimi. Emri eshte string dhe id is numer i plote pozitiv.

    Employee ka 3 konstruktora. E para nuk ka parametra, e dyta ka emrin dhe id, dhe e treta eshte kopje konstruktor.

    Klasa Employee ka metode publike e quajtur getName dhe getId qe kthejne emrin dhe id te punetorit.

    Employee ka metoden equals, toString, dhe klone. Metoda toString kthen a string qe permban datat private te anetareve.

    Employee ka nje metode abstrakte e quajtur getPay qe nuk ka parametra dhe kethen llojin double. Kjo metode kthen pagesen javore te punetorit.

    2) Projekto HourlyEmployee qe zmadhon klasen Employee. HourlyEmployee ka 2 data private te sajat, oret edhe pagesen. Oret eshte inteer edhe pagesa double. Oret jane numri i oreve per jave dhe pagesa me ore.

    HourlyEmployee has 3 konstruktors. Vendos cilat jane ato dhe shkruji ato .
    Shkruaj metodat equals, toString and clone qe duhen per HourlyEmployee. toString metoda kthen a string qe permban data private.

    Tani ver ne praktike metoden display per HourlyEmployee. Kjo metode printon HourlyEmployee emrin-id-oret-pagesen.

    Ver ne praktike metoden getPay per HourlyEmployee. Pagesa shumezohet oret * pagesa.
    3) Projekto SalariedEmployee qe zmadhojne Employee. SalariedEmployee ka 1 data private te sajen, emeruar salar. Salary is numer i plote. Salary perfaqson pagesn vjetore.

    SalariedEmployee ka 3 konsturktora. Vendos cilat jane ato dhe shkruji ato.

    Shkruaj metodat equals, toString and clone qe duhen per SalariedEmployee. toString metoda kthen a string qe permban data private.

    Ver ne praktike metoden display per SalariedEmployee. Kjo metode printon SalariedEmployee name-id,salary.

    Praktiko metoden getPay per SalariedEmployee. Pagesa eshte salary/52.0.
    4) Shkruaj nje klase te ndare e quajtur EmployeeSystem qe permban metoden kryesore. Ne metoden kryesore, krijo array per 10 punetore zgjidhi si te duash. C'do punetor eshte me pagese ne ore ose pagese e caktuar rregullisht. Perdor vetem mbiemra. Perdor numra indetifikimi te vencante per cdo punetor.

    Shkruaj kodin qe te bashkepunosh me perdoruesin duke perdorur nje menu. Menuja ka 7 opsione qe jane dhene me poshte. Menu perdor loop.

    Opsioni 1) Nqs useri zgjedh kete opsion, programi do printoje info per te gjith punetoret ne database. C'do informacion per punetorin do printohet ne nje vije duke perdorur metoden display. Kjo duhet te behet duke thirur displayAll metoden.

    Opsioni2) Nqs useri zgjedh kete opsion, programi do lexoje nje id nga perdoruesi. Pastaj do printoje info per punetorin me ate id.

    Opsioni3) Nqs useri zgjedh kete opsion atere programi do printoje info per punetorin me pagesen me te larte ne jave.

  12. #12
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Për mua do mjaftonte një përshkrim i vogël në Shqip, që të mund të kishin një ide ata që nuk dinë anglisht. Ti e paske përkthyer të gjithën. Shpërblimi im janë 3 klasat që të premtova më lart.

    Klasën e katërt është mirë ta bësh vetë, por po të kem kohë do mundohem ta bëj dhe unë.

    Kodin e ke të bashkëngjitur në ZIP. U mundova të ndiqja kërkesat e profesorit një për një por nqs ai ka kërkuar diçka specifike, ndryshoje vetë.

    Për çdo gjë që nuk kupton mos nguro të pyesësh.

    Kodi:
    abstract class Employee implements Cloneable {
        
        //======= private ===================
      
        protected String _name;
        protected int _id;
        
        //======= public ====================
       
        public Employee(){
            _name = "";
            _id = 0;
        }
       
        public Employee(String name, int id){
            _name = name;
            _id = id;
        }
       
        public Employee(Employee E){
            this._name = E._name;
            this._id = E._id;
        }
       
        public String getName(){
            return _name;
        }
       
        public int getId(){
            return _id;
        }
       
        public boolean equals(Object O) {
            if( this == O)
                return true;
            
            if( !(this.getClass() == O.getClass()) || O == null)
                return false;
            
            Employee employee = (Employee) O;
            
            return 
            this._name.equals(employee._name)
            & this._id == employee._id;
                
        }
        
        public String toString(){
            return "Name: " + _name + "\nId: " + _id;
        }
              
        public Object clone() {
            try {
                return super.clone();
            } 
            catch (CloneNotSupportedException e) { 
                throw new InternalError();
            }
    
        }
       
        public abstract double getPay();
       
    }
    
    class HourlyEmployee extends Employee implements Cloneable {
        
        //======= private ==============
        
        private int _hours;
        private double _rate;
        
        //======= public ===============
        
        public HourlyEmployee(){
            super();
            _hours = 0;
            _rate = 0.0;
        }
       
        public HourlyEmployee(String name, int id, int hours, double rate){
            super(name, id);
            _hours = hours;
            _rate = rate;
        }
       
        public HourlyEmployee(HourlyEmployee E){
            this._hours = E._hours;
            this._rate = E._rate;
        }
        
        public boolean equals(Object O) {
            if( this == O)
                return true;
            
            if( !(O instanceof Employee ) || O == null)
                return false;
            
            HourlyEmployee hemployee = (HourlyEmployee) O;
            
            return 
            this._name.equals(hemployee._name)
            & this._id == hemployee._id 
            & this._hours == hemployee._hours
            & this._rate == hemployee._rate;
                
        }
    
        public String toString(){
            return "Name: " + _name 
            + "\nId: " + _id 
            + "\nHours:" + _hours 
            + "\nRate: " + _rate;
        }
              
        public Object clone() {
            return super.clone();
        }
        
        public double getPay(){
            return _hours * _rate;
        }
        
        public void display(){
            System.out.println("HourlyEmployee-" + _name + "-" + _id + "-" + _hours + "-" + _rate );
        }
    
    }
    
    class SalariedEmployee extends Employee implements Cloneable {
        
        //======== private ==============
        
        private int _salary;
        
        //======== public ===============
        
        public SalariedEmployee(){
            super();
            _salary = 0;
        }
       
        public SalariedEmployee(String name, int id, int salary){
            super(name, id);
            _salary = salary;
        }
       
        public SalariedEmployee(SalariedEmployee E){
            this._salary = E._salary;
        }
        
        public boolean equals(Object O) {
            if( this == O)
                return true;
            
            if( !(O instanceof Employee ) || O == null)
                return false;
            
            SalariedEmployee semployee = (SalariedEmployee) O;
            
            return 
            this._name.equals(semployee._name)
            & this._id == semployee._id 
            & this._salary == semployee._salary;
                
        }
        
        public String toString(){
            return "Name: " + _name 
            + "\nId: " + _id 
            + "\nSalary:" + _salary;
        }
              
        public Object clone() {
            return super.clone();
        }
        
        public double getPay(){
            return _salary / 52.0;
        }
        
        public void display(){
            System.out.println("SalariedEmployee-" + _name + "-" + _id + "-" + _salary );
        }
            
    }
    Skedarët e Bashkëngjitur Skedarët e Bashkëngjitur
    Ndryshuar për herë të fundit nga edspace : 16-10-2004 më 23:29
    Edi

  13. #13
    i/e regjistruar Maska e pagan
    Anëtarësuar
    15-02-2004
    Postime
    227
    hej keto programet qe beni, jane detyra shkolle, apo i beni per te fitu noj lek. njoh njerin qe ben programe pa bere hiç shkolle ne informatike, e çuditshme jo !

    si dhe une them per ta bere mire nje program, duhet ne rradhe te pare ta kesh nevoje PERSONALE ate. du me thon, ai qe shpiku gozhden, eshte se kishte nevoje VET per te, e jo per t'ja shit per ti bo brimen ne mes japonezve, bie fjala .

  14. #14
    Pagan,
    nuk eshte cudi qe edhe nje prof. universiteti i anglishtes eshte programues sepse e ka talent. Shume mire e ka shprehur njeri ketu, qe nuk do brire po pak llogjike per te renditur sintaksen e kodeve, edhe te mesosh nje gjuhe eshte e lehte te alternohesh dhe tek te tjerat. Por edhe duhet, sepse shume kompani te reja kane nevoje per programe te ndryshme sipas specifikimeve qe ata parashtrojne. Shembull jane kompanite shqiptare.

    Me sa duket forumisti me lart e ka nevoje per ta mesuar sepse e ka te kerkuar ne programin e shkolles dhe mund ti duhet ne jete.
    Mua nuk mu desh faktikisht me vone. Por edhe per deshire te punosh, nuk eshte keq.
    Ndryshuar për herë të fundit nga Afer-dita : 17-10-2004 më 12:20

  15. #15
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Afer-dita,

    Nuk mendoj se programimi eshte talent, te pakten jo ashtu sic e ke shprehur ti. Mund te kete piktore (artiste) qe te marrin penelat dhe te pikturojne ne cast, por nuk ka programues qe te hapi kompjuterin per here te pare dhe te shkruaj kod.

    Programimi i mirefillte kerkon njohuri te gjere per sintaksen e gjuhes, strukturat, perpilimin, analizimin, perdorimin e programit. Programuesi duhet te kete dijeni jo vetem si te shkruaj nje program, por edhe se cfare ndodh me programin gjate perpilimit dhe gjate ekzekutimit. Keto njohuri e ndihmojne qe te shkruaj kod me te shpejte, me efektiv. Programuesi i mire meson te shkruaj kodin ne ate menyre qe mund te perdoret edhe ne te ardhmen dhe jo te perserise gjithnje te njetjin kod. Pra, ka shume njohuri jo vetem per informatiken por edhe per matematiken qe duhet te zoteroje nje programues (i mire).

    Edhe profesori i letersise mund te mesoje sintaksen dhe te shkruajne dy rreshta kod por a e ka shkruajtur ne menyren me te mire? A eshte i sigurte kodi? A punon sic duhet ne cdo kohe dhe ne cdo ambjent (so)? Sa i shpejte eshte? Jane shume gjera qe duhen marre parasysh dhe, ndryshe nga talenti, nuk jane te lindura tek njeriu dhe nuk mund te mesohen vetem nga eksperienca por duhen studiuar ne thellesi.
    Edi

  16. #16
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26
    Ky program eshte reth bankes ku mund te depozitosh edhe mund te maresh nje shume te caktuar parash.


    1. Ask for and read the customer BALANCE

    2. Ask for and read TRANSACTION TYPE

    3. While TRANSACTION TYPE is not EXIT do

    Ask for and read Transaction AMOUNT

    if TRANSACTION TYPE is DEPOSIT then

    credit transaction AMOUNT to BALANCE

    else if TRANSACTION TYPE is WITHDRAWAL then

    if BALANCE can not cover transaction AMOUNT,

    debit the customer $25.00 for insufficient funds

    else

    debit the customer for the transaction AMOUNT

    endif

    else

    print a message saying "unidentified transaction"

    endif

    Ask for and read the next TRANSACTION TYPE

    Endwhile



    Note: For each transaction, print a confirmation, and at the end, print the beginning balance, the number of each transaction and the total amounts for each category i.e. DEPOSITS, WITHDRAWAL, and BANK FEES (insufficient fund), and then the ending balance. You need to modify the steps as appropriate to be able to complete this.

    Test run your program with the following data. Input/Output should be as shown below.

    What is the starting balance: 50.05

    Enter Transaction: W

    Enter Trans. Amt: 100.00

    Insufficient fund. You have been debited $25.00. New Balance is $25.05

    Enter Transaction: D

    Enter Trans. Amt: 80.00

    Balance after Deposit: $105.05

    Deri ketu e kam mbaruar:

    import java.util.Scanner;

    public class banker {

    public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    float balance, amount;

    String transType;

    System.out.print("What is the starting balance: ");

    balance = scan.nextFloat();

    System.out.print("Enter transaction: ");

    transType = scan.next();

    System.out.println("Begining balance: "+balance);

    System.out.println("Transaction is: "+transType);



    //while (

    }

    }

  17. #17
    Edi,

    Te kuptoj shume mire se cfare do te konkludosh. Me paske keqkuptuar. Une e nentheksoj qe shume individe e kane mesuar programimin sepse e kane pasur pasion, edhe pse jo talent; ky eshte pergjithesim. Psikologjia eshte njesoj, edhe nje arkitekt mund te programoj. Nqs e ke fjalen se do te besh karriere, patjeter qe duhet studiuar literatura me ne thellesi, per te planifikuar, analizuar, implementuar, dhe ekzekutuar programin. Dokumentacioni shoqerues duhet te jete i sakte, sepse ka shume kompani qe kane paguar qimet e kokes dhe sistemi i eshte kollapsur, ose ka difekte. Kodi nuk eshte me i perdorshem. Patjeter qe futet nje pjese e fushes se matematikes, patjeter qe futen algoritmet. Nqs pasioni te ben qe ti futesh asaj pune, sigurisht qe mundesite jane te shumta.

  18. #18
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Michigansi,

    Më poshtë gjen kodin e programit të bankës për të depozituar dhe tërhequr para.
    Kam shkruajtur komente në Shqip për të gjithë kodin që ta kuptosh më mirë se çfarë ndodh.

    Në këtë program, ashtu si dhe në programin e parë për llogaritësen e kusurit, nuk përdor float, por përdor int për të bërë llogaritë me para. Arsyeja me këtë është se float ka shumë shifra pas presjes dhe i rrumbullakos ato, ndërsa shumat a parave kanë vetëm dy shifra pas presjes dhe duhet të jenë të sakta (jo me rrumbullakosje).

    Prandaj përdorim (int)(scan.nextFloat() * 100); për të marrë shumën nga përdoruesi.
    scan.nextFloat() -- marrim numrin me presje -- psh: 12,3456
    scan.nextFloat() * 100 -- e zhumëzojmë me 100 -- psh: 1234,56
    (int)(scan.nextFloat() * 100) -- marrim vetem numrin e plote -- 1234

    Pra nqs vizitori shkruan 12,3456 ne na duhet vetëm 12,34.
    Këtë e përdorim për të gjitha shumat e parave që marrim nga përdoruesi.
    Mbledhjet dhe zbritjet po ashtu i bëjmë me numra të plotë (në qindarka).
    Pastaj, kur vjen koha për ti shfaqur shumat në ekran përdorim funksionin toDollar(qindarka).

    Ky funksion merr numrin e qindarkave (psh: 1234) dhe kthen mbrapsh shumën në lek ose dollare me dy shifra pas presjes (psh: 12,34).

    Variablat e tipit int në Java kanë limit nga -2147483648 deri në 2147483647.
    Dmth nqs i tejkalojmë këto limite, programi nuk do punojë siç duhet.
    Shuma maksimale që mund të ketë personi në bankë është: $21.474.836,47

    Nqs do që programi të punojë me shuma më të mëdha se ato, të gjitha int në program ktheji në long dhe pastaj do kesh saktësi deri në shumën $92.233.720.368.547.758,07

    Po të kesh gjë të paqartë për kodin, mos ki turp të pyesësh.

    Mos kopjo kodin në faqe por merre nga skedari ZIP i bashkëngjitur se është i formatuar më mirë.

    Mos harro të heqësh komentet para se ta dorëzosh te profesori.

    Kodi PHP:
    import java.util.Scanner;

    public class 
    Banker {
        
        private 
    int balance//balanca qe gjendet ne banke
        
    private int deposit_total//shuma totale e depozitave
        
    private int withdraw_total//shuma totale e terheqjeve
            
        
    private int deposit_num//numri i depozitave te bera
        
    private int withdraw_num//numri i terheqjeve te bera
        
        
    public static void main(String[] args) {
        
            
    Banker banker = new Banker();
            
            
    int transaction//shuma e depozituar ose terhequr
            
    boolean finished false;
            
            
    Scanner scan = new Scanner(System.in);
                
            
    String trans_type//veprimi qe zgjedh perdoruesi
            //W per Withdraw, terheqje
            //D per Deposit, depozite
            //E per Exit, te mbylle programin
            
            
            //Marrim shumen fillestare te llogarise
            //E pyesim perdoruesin deri sa shuma te jete te pakten 1 qindarke
            
    do{
                
    System.out.print("What is the starting balance: $");
                
    banker.balance = (int)(scan.nextFloat() * 100);
            }while(
    banker.balance 1);
                
            do{
            
                
    //Marrim veprimin qe do te kryej perdoruesi
                
    System.out.print("Enter transaction (W/D/E): ");
                
    trans_type scan.next();
                
                if(
    trans_type.equals("W") || trans_type.equals("D")){
                    
                    
    // E pyesim perdoruesin per shumen e veprimit
                    // deri sa te shkruaj nje shume pozitive
                    
    do{
                        
    System.out.print("Enter Trans. Amt: $");
                        
    transaction = (int)(scan.nextFloat() * 100);
                    }while(
    transaction 1);
                    
                    if(
    trans_type.equals("D")){
                        
    banker.deposit(transaction);
                    }
                    else{
                        
    banker.withdraw(transaction);
                    }
                
                }
                else if(
    trans_type.equals("E")){ //nqs perdoruesi mbaroi pune
                    
    finished true;
                    
    banker.trans_summary(); //nxjerrim statistikat
                    
    System.out.println("Goodbye!");
                }
                else{
                    
    // Perdoruesi shkruaji dicka ndryshe nga W, D, E
                    // prandaj i nxjerrim gabimin ne ekran
                    
    System.out.println("Unidentified transaction.");
                    
    System.out.println("[W]ithdraw");
                    
    System.out.println("[D]eposit");
                    
    System.out.println("[E]xit");
                }
                
            }while(!
    finished);      
            
        }
        
        public 
    void withdraw(int transaction){
            
            if( 
    balance transaction){
                
    //terhiq parate, azhurno balancen
                
    balance balance transaction;
                
    withdraw_total withdraw_total transaction;
                
    withdraw_num withdraw_num 1;
                
                
    System.out.println("New Balance is $" toDollar(balance));
                
            }
            else if( 
    balance 2500 ){
                
    // nqs kerkon te terheqe me shume sec ka ne banke
                // shikojme nqs ka me shume se 25 dollare dhe po te kete
                // i japim 25 dollare
                
    balance balance 2500;
                
    withdraw_total withdraw_total 2500;
                
    withdraw_num withdraw_num 1;
                
                
    System.out.print("Insufficient fund. You have been debited $25.00.");
                
    System.out.print(" New Balance is $" toDollar(balance ));
                
    System.out.println();
                
            }
            else{
                
    //ska para te mjaftueshme per terheqje
                
    System.out.println("Insufficient funds.");
            }
            
        }
        
        public 
    void deposit(int transaction){
            
    //depozitojme parate ne llogari
            //azhurnojme balancen
            
    balance balance transaction;
            
    deposit_total deposit_total transaction;
            
    deposit_num deposit_num 1;
            
    System.out.println("Balance after Deposit: $" toDollar(balance ));
                    
        }
        
        public 
    void trans_summary(){
            
    //balanca fillestare
            
    int starting_balance balance deposit_total withdraw_total;
            
            
    System.out.println("Your starting balance was $" toDollar(starting_balance));
            
    System.out.println("You made " withdraw_num " withdrawals with a total of $" toDollar(withdraw_total ));
            
    System.out.println("You made " deposit_num " deposits with a total of $" toDollar(deposit_total ));
            
    System.out.println("Your new balance is " toDollar(balance) );
        }
        
        
    //marrim nje int dhe e kthejme ne shume parash
        //psh: 5423 = 54.23, 9000 = 90.00
        
    private static float toDollar(int cents){
            return (float)(
    cents 100.0);
        }


    Skedarët e Bashkëngjitur Skedarët e Bashkëngjitur
    Ndryshuar për herë të fundit nga edspace : 21-10-2004 më 01:32
    Edi

  19. #19
    serioz
    Anëtarësuar
    20-09-2004
    Vendndodhja
    usa
    Postime
    26
    Edspace sa her qe e bej compile c'fardo qofte lloj programi me jep error: Cannot resolve symbol---Scanner scan = new Scanner(System.in);

    Une perdor blueJ edhe xbuilder prandaj doja te dija se si mund ta perdor kete klasen?
    Me perpara kam perdorur keyboard class por tani eshte bere update edhe me duhet te perdor Scanner scan = new Scanner(System.in); ose nqs duhet te bej install dicka tjeter qe te funksionoje ajo klase.

    thx in advance

  20. #20
    Programues Softueresh Maska e edspace
    Anëtarësuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,573
    Citim Postuar më parë nga Michigansi
    Edspace sa her qe e bej compile c'fardo qofte lloj programi me jep error: Cannot resolve symbol---Scanner scan = new Scanner(System.in);

    Une perdor blueJ edhe xbuilder prandaj doja te dija se si mund ta perdor kete klasen?
    Me perpara kam perdorur keyboard class por tani eshte bere update edhe me duhet te perdor Scanner scan = new Scanner(System.in); ose nqs duhet te bej install dicka tjeter qe te funksionoje ajo klase.
    Scanner e përdora sepse ti atë kishe dhënë në kërkesën e programit. Scanner është pjesë e versionit 1.5 të Java dhe ti duhet të kesh këtë që të punojë. Unë këtë klasë e përdora edhe në detyrën e mëparshme që llogariste numrin e monedhave të kusurit dhe ti nuk kishe problem me atë kod.

    Nqs po përdor ndonjë program tjetër të duhet të instalosh Java SE 5.0 . Shkarkoje nga kjo faqe. Eshte rreth 50MB.

    Shko tek start > control panel > add/remove programs dhe hiq ndonjë version të vjetër që mund të kesh si Java JDK 1.4. Pasi të heqësh atë instalo atë më lart dhe provo të përpilosh (compile) edhe njëherë kodin. Mund të duhet të rikonfigurosh BlueJ xBuilder që të shikojë se ku është JDK i ri, ti tregosh dosjen e instalimit.
    Edi

Faqja 0 prej 3 FillimFillim 12 FunditFundit

Tema të Ngjashme

  1. OpenCD (programe cilësore me burim të hapur, shqip)
    Nga helios në forumin Lajme nga informatika
    Përgjigje: 2
    Postimi i Fundit: 26-11-2008, 08:58
  2. Të dhënat fosile hedhin poshtë evolucionin
    Nga monarku në forumin Shkenca dhe jeta
    Përgjigje: 17
    Postimi i Fundit: 02-11-2006, 10:34
  3. 2 programe per heqje zhurmash per kenge/video
    Nga benseven11 në forumin Lajme nga informatika
    Përgjigje: 7
    Postimi i Fundit: 03-12-2004, 06:14

Regullat e Postimit

  • Ju nuk mund të hapni tema të reja.
  • Ju nuk mund të postoni në tema.
  • Ju nuk mund të bashkëngjitni skedarë.
  • Ju nuk mund të ndryshoni postimet tuaja.
  •