473,490 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

arrays and for loop

9 New Member
I want to how I can put the char array and the int array together in a for loop?

This is what I got:

I type this in are the variables were intialized:
do


for(workers = 0; workers <= NUM_NAME; workers++)
{
cout << "NAME " << workers + 1 << ":" << name[workers] << "\n";
for(hours = 0; hours <= NUM_HOURS; hours++)
cin >> workers_info[workers][hours];
}






break;
The output:




Welcome to the Work Hours Tracking System
=========================================
A - Enter work hours for individual worker
B - Display report for individual worker
C - Display report for all workers
E - Exit
Please make a selection:
c
Work Hours Report:
NAME 1:Mary Johnson
c
NAME 2:Jason Garcia
NAME 3:Roy Williams
NAME 4:Jane Rose
NAME 5:╠╠╠╠╠╠╠╠♦
Press any key to continue . . .



and I need a code or a psuedo code to make the output look like this:

Welcome to the Work Hours Tracking System
=========================================
A - Enter work hours for individual worker
B - Display report for individual worker
C - Display report for all workers
E - Exit

Please enter your selection : C


Work Hours Report:

NAME Mon Tue Wed Thu Fri

Mary Johnson 4 3 4 4 0
Jason Garcia 5 5 5 4 0
Roy Williams 5 5 5 5 0
Jane Rose 4 0 4 3 0


Any questions of what is written let me know

Thanks
Mar 20 '08 #1
4 1530
weaknessforcats
9,208 Recognized Expert Moderator Expert
How are your arrays defined?

Your code has them a two-dimensional array and I expect that is not accurate.
Mar 20 '08 #2
Learner21
9 New Member
How are your arrays defined?

Your code has them a two-dimensional array and I expect that is not accurate.

Well these are my variables for them:

#define NUM_NAME 4
#define NUM_HOURS 5

int work_hours[4][5] = { {4, 3, 4, 4, 0},
{5, 5, 5, 4, 0},
{5, 5, 5, 5, 0},
{4, 0, 4, 3, 0}};
char name[4][13] = { {"Mary Johnson"},
{"Jason Garcia"},
{"Roy Williams"},
{"Jane Rose"}};

int hours = 0;
int workers = 0;
int workers_info[NUM_NAME][NUM_HOURS];



honestly I am lost I really need some help please I need some help

Thanks
Mar 20 '08 #3
weaknessforcats
9,208 Recognized Expert Moderator Expert
This code:
for(workers = 0; workers <= NUM_NAME; workers++)
{
cout << "NAME " << workers + 1 << ":" << name[workers] << "\n";
for(hours = 0; hours <= NUM_HOURS; hours++)
cin >> workers_info[workers][hours];
}
will ask for 5 names and 6 hour entries for each name. It should be asking for 4 names and 5 hour entries for each name.

Those loops should be using < rather than <= as the test.
Mar 21 '08 #4
Learner21
9 New Member
This code:


will ask for 5 names and 6 hour entries for each name. It should be asking for 4 names and 5 hour entries for each name.

Those loops should be using < rather than <= as the test.


Thanks so much hopefully you can help me with getting the hours to show up and only press the C once to have the whole report to show up. This is what the output looks like this:

Welcome to the Work Hours Tracking System
=========================================
A - Enter work hours for individual worker
B - Display report for individual worker
C - Display report for all workers
E - Exit
Please make a selection:
c
Work Hours Report:
NAME 1:Mary Johnson
0012FEB4
0012FEC8
0012FEDC
0012FEF0
0012FF04
c
NAME 2:Jason Garcia
0012FEB4
0012FEC8
0012FEDC
0012FEF0
0012FF04
NAME 3:Roy Williams
0012FEB4
0012FEC8
0012FEDC
0012FEF0
0012FF04
NAME 4:Jane Rose
0012FEB4
0012FEC8
0012FEDC
0012FEF0
0012FF04
Press any key to continue . . .


It should be where I could see the row of the names and then the column of hours. Thanks again
Mar 22 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

35
3595
by: Troll | last post by:
Hi, I need to write a script which reads some data and reports the findings. Just to give you an idea the structure is similar to the following. Data input example: HEADING 1 **********...
9
6650
by: Charles Banas | last post by:
i've got an interesting peice of code i'm maintaining, and i'd like to get some opinions and comments on it, hopefully so i can gain some sort of insight as to why this works. at the top of the...
2
7033
by: assgar | last post by:
Hi Developemnt on win2003 server. Final server will be linux Apache,Mysql and PHP is being used. I use 2 scripts(form and process). The form displays multiple dynamic rows with chechboxs,...
5
2172
by: M. Fisher | last post by:
Pardon my ignorance here... I have created arrays such as: var SDET_Lab130= new Array(); SDET_Lab130 = new Array(); SDET_Lab130 = ; SDET_Lab130 = ; SDET_Lab130 = ; SDET_Lab130 = ;...
1
2431
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
0
7142
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5445
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3071
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.