CARI Infonet

 Forgot password?
 Register

ADVERTISEMENT

View: 3526|Reply: 6

Need help with C Programming

[Copy link]
Post time 19-10-2011 04:56 PM | Show all posts |Read mode
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
Reply

Use magic Report


ADVERTISEMENT


Post time 27-10-2011 03:46 AM | Show all posts
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 ?
Reply

Use magic Report

Post time 28-10-2011 08:27 AM | Show all posts
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

Use magic Report

Post time 29-10-2011 12:43 AM | Show all posts
Reply 1# jack_stingray

yeah here we go

  1. #include <iostream>
  2. using namespace std;

  3. void main() {

  4.     int hour[3][3], thour[3];
  5.     double salary[3];

  6.     for (int a=0;a<3;a++) {
  7.         for (int b=0;b<3;b++) {
  8.             cout<<"Enter hour for worker "<<a+1<<" day "<<b+1<<" : ";
  9.             cin>>hour[a][b];                           
  10.         }            
  11.     }

  12.     cout<<"\nPtimer\tDay1\tDay2\tDay3\tTotal Hour\tSalary"<<endl;

  13.     for (int c=0;c<3;c++) {        
  14.         thour[c]=hour[c][0]+hour[c][1]+hour[c][2];
  15.         salary[c]=( (hour[c][0]+hour[c][1]) * 4.5 + hour[c][2]*8 );   
  16.         
  17.         cout<<c+1<<"\t"<<hour[c][0]<<"\t"<<hour[c][1]<<"\t"<<hour[c][2]<<"\t"<<thour[c]<<"\t\t"<<salary[c]<<endl;
  18.     }

  19. }
Copy the Code
Reply

Use magic Report

Post time 15-7-2012 03:20 AM | Show all posts
Reply 2# pengodam


   who says this is malay forum?
Reply

Use magic Report

Post time 15-7-2012 05:07 PM | Show all posts
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?
Reply

Use magic Report

Follow Us
Post time 6-8-2012 07:05 AM | Show all posts
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
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CARI Infonet

27-4-2024 05:21 PM GMT+8 , Processed in 0.060351 second(s), 33 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list