Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

SEC, 001/060 Fall 2016 Name (Print) The following code prints \"Nice to meet you

ID: 3583259 • Letter: S

Question

SEC, 001/060 Fall 2016 Name (Print) The following code prints "Nice to meet you! 5 times 3) int while count S cout Nice to meet you end count 1 Part IV. Algorithm (10 pts) In a C+ program you need to store the identification numbers of 10 employees (as ints and their weekly gross pay (as doubles). 1) the the that define two arrays named id and pay that may be used in parallel to store the 10 employee identification numbers and gross pay amounts. 2) Assume the employee identification numbers and gross pay amounts have already been entered into the above two arrays. Write a loop (not the complete program) that uses these two arrays to output each employee's identification number and weekly pay.

Explanation / Answer

3) Program:

#include <iostream>
using namespace std;

int main() {
int count=0;
while(count<5)
{
cout << "Nice to meet you" << endl;
count++;// Here we are incrementing the value of count by 1
}
}

Output: //The above program prints the message " Nice to meet you " 5 times

Nice to meet you
Nice to meet you
Nice to meet you
Nice to meet you
Nice to meet you

1) Program:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void displayEmployee( int Id[],int P[]);// Here we are declaring the method named as displayEmployee
int main()
{
int id[] = {1,2,3,4,5,6,7,8,9,10}; // Here we are decalring array name as id
int pay[] = {15000,10000,20000,12000,14000,8000,9000,25000,30000,50000};

// Here we are decalring array name as pay

  displayEmployee(id,pay);// Here we are displaying both employee id and pay
}
void displayEmployee(int Id[],int P[])
{
int w=0;
cout << setw(7) << "Employee Id numbers" << setw(7) << "Gross Pay Amount" << endl;
cout << setw(7) << "----------------------------" << setw(7) << "----------------------------------" << endl;
for(int s = 0; s <10; s++)
{
cout << setw(7) << Id[s] << " " ;

if(w <10)
{
cout << setw(7) << P[w] << " ";
w++;
}
cout << " ";
}
}

Output:

Employee Id numbers Gross Pay Amount
--------------------------------------------------------------
1 15000
2     10000
3     20000
4     12000
5     14000
6     8000
7     9000
8     25000
9     30000
10     50000

2) Program:

#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
void displayEmployee( int Id[],int P[]);
int main()
{
int id[] = {1,2,3,4,5,6,7,8,9,10};
int pay[] = {2142,1428,2857,1714,2000,1142,1285,3571,4285,7142};


displayEmployee(id,pay);
}
void displayEmployee(int Id[],int P[])
{
int w=0;
cout << setw(7) << "Employee Id numbers" << setw(7) << "Weekly Pay Amount" << endl;
cout << setw(7) << "-----------------------" << setw(7) << "-------------------------" << endl;
for(int s = 0; s <10; s++)
{
cout << setw(7) << Id[s] << " " ;

if(w <10)
{
cout << setw(7) << P[w] << " ";
w++;
}
cout << " ";
}
}

Output:

Employee Id numbers Weekly Pay Amount
------------------------------------------------
1 2142
2 1428
3 2857
4 1714
5 2000
6 1142
7 1285
8 3571
9 4285
10 7142