Close
Faqja 0 prej 5 FillimFillim 12 ... FunditFundit
Duke shfaqur rezultatin -9 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,565
    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,565
    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,565
    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,565
    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

Faqja 0 prej 5 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.
  •