Need help with C Programming
Post Last Edit by jack_stingray at 19-10-2011 17:00Hello 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 :lol:
#include <iostream>
using namespace std;
void main() {
int hour, thour;
double salary;
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;
}
}
cout<<"\nPtimer\tDay1\tDay2\tDay3\tTotal Hour\tSalary"<<endl;
for (int c=0;c<3;c++) {
thour=hour+hour+hour;
salary=( (hour+hour) * 4.5 + hour*8 );
cout<<c+1<<"\t"<<hour<<"\t"<<hour<<"\t"<<hour<<"\t"<<thour<<"\t\t"<<salary<<endl;
}
} Reply 2# pengodam
who says this is malay forum? Replypengodam
who says this is malay forum?
hlyh1230 Post at 15-7-2012 03:20 http://mforum2.cari.com.my/images/common/back.gif
bro, who u are try to up old thread with nonsense issue? hlyh1230 posted on 15-7-2012 03:20 AM static/image/common/back.gif
Reply 2# pengodam
the banner above says it pretty clear for me.
http://mforum.cari.com.my/static/image/common/mlogo.png Last edited by bzzts on 6-8-2012 07:06 AM \n\n
Pages:
[1]