View: 3591|Reply: 6
|
Need help with C Programming
[Copy link]
|
|
Post Last Edit by jack_stingray at 19-10-2011 17:00
Hello everyone,
I am new to C programming, does anyone have idea how to do this? The actual question is much longer than this, i edited the question to make it shorter just to understand the concept. Hope somebody could show me the proper way to develop the answer for this question:
The following Table 1 that manipulates a two-dimensional array stores the work hours for three employees. Each row stores the employee’s three-day work hours with four columns. Write, run and test a C program that reads the hours, calculates total hours and salary and displays all fields, employee’s total hours and salary.
Note: Day1 and Day 2 salary rate: RM4.50 per hour
Day3 salary rate: RM8.00 per hour
Ptimer Day1 Day2 Day3
Max 4 3 2
John 2 2 2
Jane 3 4 4
TABLE 1
Sample Output:
Ptimer Day1 Day2 Day3 Total Hour Salary
Max 4 3 2 9 $47.50
John ... ... ... ... ...
Jane ... ... ... ... ...
TABLE 2 |
|
|
|
|
|
|
|
hurm.. maaf la. aku rasa better ko tulis persoalan tu dlm bahasa BM (rojak pun xpe)
lgpun ni kan board utk bahasa melayu .. pastu persoalan C dgn array 2D ni dah setel lum ? |
|
|
|
|
|
|
|
Post Last Edit by otai_g at 28-10-2011 23:50
will see back.
the question is very straight forward...
but still need to do next yeah... |
|
|
|
|
|
|
|
Reply 1# jack_stingray
yeah here we go
- #include <iostream>
- using namespace std;
- void main() {
- int hour[3][3], thour[3];
- double salary[3];
- for (int a=0;a<3;a++) {
- for (int b=0;b<3;b++) {
- cout<<"Enter hour for worker "<<a+1<<" day "<<b+1<<" : ";
- cin>>hour[a][b];
- }
- }
- cout<<"\nPtimer\tDay1\tDay2\tDay3\tTotal Hour\tSalary"<<endl;
- for (int c=0;c<3;c++) {
- thour[c]=hour[c][0]+hour[c][1]+hour[c][2];
- salary[c]=( (hour[c][0]+hour[c][1]) * 4.5 + hour[c][2]*8 );
-
- cout<<c+1<<"\t"<<hour[c][0]<<"\t"<<hour[c][1]<<"\t"<<hour[c][2]<<"\t"<<thour[c]<<"\t\t"<<salary[c]<<endl;
- }
- }
Copy the Code |
|
|
|
|
|
|
|
Reply 2# pengodam
who says this is malay forum? |
|
|
|
|
|
|
|
Reply pengodam
who says this is malay forum?
hlyh1230 Post at 15-7-2012 03:20
bro, who u are try to up old thread with nonsense issue? |
|
|
|
|
|
|
|
hlyh1230 posted on 15-7-2012 03:20 AM
Reply 2# pengodam
the banner above says it pretty clear for me.
Last edited by bzzts on 6-8-2012 07:06 AM \n\n |
|
|
|
|
|
|
| |
|