Jump to content

khairiez

Members
  • Content Count

    94
  • Joined

  • Last visited

Posts posted by khairiez


  1. [code]
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.Label.*;

    class project001 extends JFrame implements ActionListener {

    private static final int FRAME_WIDTH = 500;
    private static final int FRAME_HEIGHT = 400;
    private static final int FRAME_X_ORIGIN = 250;
    private static final int FRAME_Y_ORIGIN = 300;

    private JLabel prompt;
    private JButton enterButton;

    public static void main(String[] args) {
    project001 frame = new project001();
    frame.setVisible(true);
    }

    public project001() {
    Container contentPane;

    setSize(FRAME_WIDTH, FRAME_HEIGHT);
    setResizable(false);
    setTitle("Student Information System");
    setLocation(FRAME_X_ORIGIN, FRAME_Y_ORIGIN);

    contentPane = getContentPane();
    contentPane.setLayout(null);
    contentPane.setBackground(Color.WHITE);

    Font f = new Font("Tahoma", Font.BOLD, 28);

    prompt = new JLabel();
    prompt.setText("Student Information System");
    prompt.setSize(500, 100);
    prompt.setHorizontalAlignment(SwingConstants.CENTER);
    prompt.setFont(f);
    contentPane.add(prompt);

    enterButton = new JButton("ENTER");
    enterButton.setBounds(200, 300, 80, 30);
    contentPane.add(enterButton);

    enterButton.addActionListener(this);

    setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public void actionPerformed(ActionEvent event) {
    JButton clickedButton = (JButton) event.getSource();

    // ????

    }
    }
    [/code]

    stakat nie je aku wat n kalo bleh button enter tu gi kat frame laen..
    mcm mane ye coding nye... aku da try google tp xdpt n ade yg x phm..
    tolong ye..

  2. salam dan selamat sejahtera..

    saya nie baru lg blaja c++ tp masalahnye bile kite compile source code tersebut, msti command prompt tu akan kuar..
    ade x care kite nak display more graphical user interface..???
    mcm application la jdnye... xde la display screen gelap je...
    mintak tolong ajar ye....

    terima kasih..

  3. btol la tu....

    [code]int kira_gaji(double B)[/code] sahaja melaenkan ade declaration dlm fungsi tersebot..

    kalo ade declaration msti ade proses dlm fungsi terebut...

    tp yg hairan nape 6 markah.. bese soalan mcm nie 1 atau 2 markah...

  4. aku pon gune celcom broadband ni bulan 10 tahun lepas... smpai skang okeyh.. pkai pakej d68..
    laju je.. kire speed die average la.. xde la melampau2 lajunye... tp depends jgk on masa.. kalo siang laju la tp da nk start mlm mula la cam sipot...
    tp skang aku da tukar pakej.. pkej student... rm50 sebulan.. worth it la.... bg aku student kat u nie... xyah mahal2 jnji leh bkk elearning aku..

  5. accessor nie bermaksud apabila sesuatu "member function" nie yg dpt value dr "class memmber" tetapi nilainye x berubah... 2 la accessor..

    contoh:-
    [code]
    class rectangle
    {
    private:
    double width;
    double length;
    public:
    void setWidth(double);
    void setLength(double);
    double getWidth() const;
    double getLength() const;
    double getArea() const;
    };
    [/code]

    "member function" getlength dan getWidth 2 la accessors..

    kalau nak print out plak...
    [code]
    double rectangle::getWidth() const
    {
    return width;
    }
    [/code]

    make sure value da pass dlm function main..

  6. salam semua.. yg nie jawapan kpada soalan sy yg lepas...

    [code]#include <iostream>
    #include <string>
    #include <iomanip>
    #include <fstream>
    using namespace std;

    struct Visitors
    {
    string attractionName;
    long totalVisitors;
    int visitorByQuarter[4];
    };

    void getData (Visitors []);
    int *visitorByQuarter (Visitors []);
    void totalVisitorByAttraction (Visitors []);
    void printReport (Visitors [], int *, int, string &, int &, string &, int & );
    void maxVisitorByQuarter (int *, string &, int &);
    void maxVisitorByAttraction (Visitors [], string &, int &);
    int getTotal (int *);

    int main()
    {
    Visitors attract[9];
    int max_num_attract, max_num_quart;
    string max_name_attract, max_name_quart;
    int *total_quarter;
    int total;

    getData (attract);
    total_quarter = visitorByQuarter (attract);
    totalVisitorByAttraction (attract);
    total = getTotal(total_quarter);
    maxVisitorByAttraction(attract, max_name_attract, max_num_attract);
    maxVisitorByQuarter(total_quarter, max_name_quart, max_num_quart);
    printReport(attract, total_quarter, total, max_name_attract, max_num_attract, max_name_quart, max_num_quart);

    delete [] total_quarter;
    total_quarter = 0;

    system ("pause");
    return 0;
    }


    void getData(Visitors v[])
    {
    ifstream InData ("Report of Malaysian Tourism.txt", ios::in);
    for(int x=0; x<9; x++)
    {
    getline(InData, v[x].attractionName, ',');
    for(int y=0; y<4; y++)
    {
    InData>>v[x].visitorByQuarter[y];
    InData.get();
    }
    }
    InData.close();
    }


    int *visitorByQuarter (Visitors w[])
    {
    int *qrtr;
    qrtr = new int[4];
    for(int x=0; x<4; x++)
    {
    qrtr[x] = 0;
    for(int y=0; y<9; y++)
    qrtr[x] += w[y].visitorByQuarter[x];
    }

    return qrtr;
    }


    void totalVisitorByAttraction (Visitors q[])
    {
    for(int x=0; x<9; x++)
    {
    q[x].totalVisitors=0;
    for(int y=0; y<4; y++)
    q[x].totalVisitors += q[x].visitorByQuarter[y];

    }

    }


    int getTotal (int *gt)
    {
    int a=0;
    for(int x=0; x<4; x++)
    a += gt[x];
    return a;
    }


    void maxVisitorByAttraction (Visitors t[], string &k, int &l)
    {
    int max,num;
    max = t[0].totalVisitors;
    num = 0;
    for(int x=1; x<9; x++)
    {
    if(t[x].totalVisitors > max)
    {
    max = t[x].totalVisitors;
    num = x;
    }
    }
    k = t[num].attractionName;
    l = t[num].totalVisitors;
    }


    void maxVisitorByQuarter (int *d, string &b, int &c)
    {
    int max, num;
    max = d[0];
    num = 0;
    for(int x=1; x<4; x++)
    {
    if(d[x] > max)
    {
    max = d[x];
    num = x;
    }
    }

    switch(num)
    {
    case 0: b = "QT1('09)";
    c = d[0];
    break;
    case 1: b = "QT2('09)";
    c = d[1];
    break;
    case 2: b = "QT3('09)";
    c = d[2];
    break;
    case 3: b = "QT4('09)";
    c = d[3];
    break;
    }
    }


    void printReport (Visitors a[], int *tq, int t, string &w, int &y, string &x, int &z)
    {
    for(int m=0; m<25; m++)
    cout<<"-";
    cout<<"Annual Malaysian Tourism Report";
    for(int m=0; m<24; m++)
    cout<<"-";
    cout<<left<<setw(20)<<"Attraction";
    cout<<setw(12)<<"QT1('09)";
    cout<<setw(12)<<"QT2('09)";
    cout<<setw(12)<<"QT3('09)";
    cout<<setw(12)<<"QT4('09)";
    cout<<setw(12)<<"Total";

    for(int n=0; n<9; n++)
    {
    cout<<left<<setw(20)<<a[n].attractionName;
    cout<<setw(12)<<a[n].visitorByQuarter[0];
    cout<<setw(12)<<a[n].visitorByQuarter[1];
    cout<<setw(12)<<a[n].visitorByQuarter[2];
    cout<<setw(12)<<a[n].visitorByQuarter[3];
    cout<<setw(12)<<a[n].totalVisitors;
    }

    cout<<left<<setw(20)<<"Total";
    cout<<setw(12)<<tq[0];
    cout<<setw(12)<<tq[1];
    cout<<setw(12)<<tq[2];
    cout<<setw(12)<<tq[3];
    cout<<setw(12)<<t;

    cout<<endl<<endl;

    cout<<"Max Number of Visitor by Attraction: " <<w<< ",";
    cout<<"Number of Visitor = "<<y<<endl<<endl;

    cout<<"Max Number of Visitor by Quarter: Quarter= " <<x<< ",";
    cout<<"Number of Visitor = "<<z<<endl<<endl;
    }

    [/code]

    saya ade masalah laen plak.. yg nie sy kene wat projek tentang hotel reservation..
    compiler pkai dev c++... yg nie masalahnye, bile masuk input kat address line 2 die akan loop selepas masok input nye...
    tolong ye.....

    [code]#include <iostream>
    #include <fstream>
    #include <string>
    using namespace std;

    class hotel
    {
    private:
    string name, occupation;
    int tel_No;
    char IC_No[15], address1[51], address2[51];
    public:
    void showMenu();
    void form();
    };

    void hotel::showMenu()
    {
    cout << "\t\tHotel Reservation System\n\n";
    cout << "1. Booking for room\n";
    cout << "2. Display the Information\n";
    cout << "3. List of Rooms\n";
    cout << "4. Search\n";
    cout << "5. Quit the Program\n\n";
    cout << "Enter your choice: ";
    }

    void hotel::form()
    {
    cout << "Please fill up the information below: \n";
    cout << "Name: ";
    getline(cin, name);
    cin.ignore();
    cout << "IC Number: ";
    cin.getline(IC_No, 15);
    cin.ignore();
    cout << "Occupation: ";
    getline(cin, occupation);
    cin.ignore();
    cout << "Address line 1: ";
    cin.getline(address1, 51);
    cin.ignore();
    cout << "Address line 2: ";
    cin.getline(address2, 51); <== masuk input die akan loop memanjang..
    cin.ignore();
    cout << "Telephone No: ";
    cin >> tel_No;

    cout << "Thank you!\n";
    }


    int main()
    {
    hotel reserve;
    int choice;

    do
    {
    reserve.showMenu();
    cin >> choice;
    cout << endl;
    while (choice < 1 && choice > 4)
    {
    cout << "Please enter 1, 2, 3, 4, 5: ";
    cin >> choice;
    }
    if (choice != 4)
    {
    switch(choice)
    {
    case 1: reserve.form();
    break;
    }
    }
    } while (choice != 5);

    system("PAUSE");
    return 0;
    }

    [/code]

  7. [code]void printReport(Visitors &y) // yg nie utk output data
    {
    for (int c = 0; c < 2; c++)
    {
    cout << y.attractionName[c] << "\t";
    for (int d = 0; d < QRTR; d++)
    {
    cout << y.visitorByQuarter[d] << " ";
    }
    cout << endl;
    }
    }[/code]

    yang nie problem la... input nombor pastu kuar yg same...
    mcm ne eh....??

  8. oooo..
    okeyh3...

    thankx... nie pon skang ngah ask google... :lol:

    [code]
    #include <iostream>
    #include <string>
    using namespace std;

    const int QRTR = 4;

    struct Visitors
    {
    string attractionName[2];
    long totalVisitors;
    int visitorByQuarter[QRTR];
    };

    int getData(Visitors &);
    void printReport(Visitors &);


    int main()
    {
    Visitors v;

    getData(v);
    printReport(v);

    system ("pause");
    return 0;
    }

    int getData(Visitors &x) // yg ni utk input data
    {

    for (int a = 0; a < 2; a++)
    {
    cout << "Please insert your attraction name: ";
    getline(cin, x.attractionName[a]); // yg ni confius
    for (int b = 0; b < QRTR; b++)
    {
    cout << "Please insert your quarter " << (1 + B) << ": ";
    cin >> x.visitorByQuarter[b];
    cin.ignore();
    }
    cout << endl;
    }

    }

    void printReport(Visitors &y) // yg nie utk output data
    {
    for (int c = 0; c < 2; c++)
    {
    cout << y.attractionName[c] << "\t";
    for (int d = 0; d < QRTR; d++)
    {
    cout << y.visitorByQuarter[d] << " ";
    }
    cout << endl;
    }
    }
    [/code]

    kire nie la last aku update.... bleyh execute n run... thanx kamu semua bg idea..
    nie pon aku wat step by step... cari output display mcm ne baru wat care nk input..
    x c0mplete nie lg... huhu.. ^_^

  9. haha... okeyh... kepada sape2 yg phm tu t0long la sementara aku scan kn soalan die... ^_^
    masalah nye skang aku nak loop kn string.... string tu
    nak store sbg array aku xbape reti la... lg satu kalo string kite call blk mzti die
    pggl word pertama.... contoh: aku cin john smith then aku called blk mzti kuar john sahaje..


    nie contoh yg aku da buat la...

    #include <iostream>
    #include <string>
    using namespace std;

    const int QRTR = 4;

    struct Visitors
    {
    string attractionName[3];
    long totalVisitors;
    int visitorByQuarter[QRTR];
    };

    void getData(Visitors &);
    void printReport(Visitors &);


    int main()
    {
    Visitors v;

    getData(v);
    printReport(v);

    system ("pause");
    return 0;
    }

    void getData(Visitors &x) // yg ni utk input data
    {

    for (int a = 0; a < 3; a++)
    {
    cout << "Please insert your attraction name: ";
    cin >> x.attractionName[a]; // yg ni confius
    for (int b = 0; b < QRTR; b++)
    {
    cout << "Please insert your quarter " << (1 + B) << ": ";
    cin >> x.visitorByQuarter[b];
    }
    cout << endl;
    }

    }

    void printReport(Visitors &y) // yg nie utk output data
    {
    for (int c = 0; c < 9; c++)
    {
    cout << y.attractionName[c] << "\t";
    for (int d = 0; d < QRTR; d++)
    {
    cout << y.visitorByQuarter[d] << " ";
    }
    cout << endl;
    }
    }

  10. // input
    Tasik Kenyir, 937, 456, 900, 879
    Pulau Tioman, 810, 80, 589, 456
    Bukit Tinggi, 2500, 900, 6789, 459
    ..... and so on

    //output
    ----------------------------Annual Malaysian Tourism Report---------------------------
    Attraction QT1('09) QT2('09) QT3('09) QT4('09) Total
    Tasik Kenyir 937 456 900 879 XXXXX
    Pulau Tioman 810 80 589 456 XXXXX
    Bukit Tinggi 2500 900 6789 458 XXXXX
    ......
    Total XXXXX XXXX XXXX XXXX XXXXX


    // questions
    Develop a program that uses an array of structures that store the following information:
    - attractionName
    - totalVisitors
    - visitorsByQuarter

    function getData
    -loads the data into the array

    function visitorByQuarter
    -finds the attraction's total visitors for each quarter.

    function totalvisitorByAttraction
    -find each attraction's yearly number of visitors

    function printReport
    -print the annual report in the format specified above.

    kepada sesiapa yang mahu sudi membantu......

  11. bukan kat kafe c la...kat dewan utama tu....bertolak kul 8pg....

    tu la ko....asyik2 ngan aci maci jer....hihi....sampai xtau ada benda ni....

    ada membe aku bangga ngan matrik n.s dier...dpt no.2 dlm keseluruhan matrik...no.1 penang....

    aku panass......

    haha....

    tahun ni kiter buat yg terbaik punyaa....!!!

    kasi no.1...haha....insyaAllah....

    ceh.....

    sabOr je la.......

    lgpOn aku xtau lgsg.....

    btOl tu....

    taun niew kene dO d best...!!!

    aku tyme orientasi ilek2 jew....

    lpas sOlat aku blk blOk n saje wat lmbat....

    dpt dOk blkg skali.... siap leh blaja aku tyme dgr ceramah tah ke mende aku x phm....

    hOhOho........

×
×
  • Create New...