hello guyz im afraid if i understood this assignment unproperly:
could you give me the output of it plz? (how should the output of this assign be)

The monthly results for the best 3 employees of the month in a company are sent to the IT department for analysis and calculation in the following format:

1378 2496 3587

Those results are read as follows:
Example:
1378: 1 for the candidate number.
3 grade over 10 for Self-motivation.
7 grade over 10 for Professionalism.
8 grade over 10 for Teamwork.

The coefficients for the 3 attributes above are respectively:
Self-motivation: 5
Professionalism: 2
Teamwork: 3

Result for Employee 1 is: (3x5) + (7x2) + (8x3) = 53
Where the maximum result will be 90: (9x5) + (9x2) + (9x3)

Write a program to do the following:
1. Read and store the results for the 3 employees from the keyboard.

1. Calculate and print the result for each of the 3 employees.

THx!!

So what do you have so far? This site is not about giving it is about helping. If you put in the effort we will help you. help does not equal do.

commented: Well said! +15

im afraid if i understood this assignment unproperly:

Seems pretty clear assignment to me. What part don't you understand?

Since you have to work with each digit of the number it would probably be easier to get the number as a string instead of an integer. It can be done with an integer but it's a little more complicated.

hey bro can you check for me if this code is correct plz ? thank you

``````#include <iostream>
#include "stdafx.h"
using namespace std;

int main()

{
int result1,result2,result3, counter=0,x=0,y=0,z=0,z1,y1;

while(counter<1)
{
cout<<"Enter the first result: ";
cin>>result1;
while (result1>9999) {
cout<<"you need to enter four digits. Type again: ";
result1=0;
cin>>result1;
}
cout<<"Enter the second result: ";
cin>>result2;
while (result2>9999) {
cout<<"you need to enter four digits. Type again: ";
result2=0;
cin>>result2;
}
cout<<"Enter the third result: ";
cin>>result3;
while (result3>9999) {
cout<<"you need to enter four digits. Type again: ";
result3=0;
cin>>result3;
}
counter=counter+1;
}

cout<<"The results are the following:"<<endl;

x=(result1%1000%100%10);
y1=(result1%1000%100)-(x);
y=y1/10;
z1=(result1%1000)-(result1%1000%100);
z=z1/100;
result1=(x*3)+(y*2)+(z*5);
cout<<"First result is: "<<result1<<endl;
x=(result2%1000%100%10);
y1=(result2%1000%100)-(x);
y=y1/10;
z1=(result2%1000)-(result2%1000%100);
z=z1/100;
result2=(x*3)+(y*2)+(z*5);
cout<<"Second result is: "<<result2<<endl;
x=(result3%1000%100%10);
y1=(result3%1000%100)-(x);
y=y1/10;
z1=(result3%1000)-(result3%1000%100);
z=z1/100;
result3=(x*3)+(y*2)+(z*5);
cout<<"Third result is: "<<result3<<endl;

if(result1>result2 && result1>result3)
cout<<"The winner is the first employee."<<endl;
if(result3>result1 && result3>result2)
cout<<"The winner is the third employee."<<endl;
if(result2>result3 && result2>result1)
cout<<"The winner is the second employee."<<endl;

return 0;
}
``````

hello ancient dragon. Thank you for your support. The part that i dont understand is the coefficient part "The coefficients for the 3 attributes above are respectively:
Self-motivation: 5
Professionalism: 2
Teamwork: 3"
Does it mean that if i put for example:
2453
3453
6323
the result 1 should be : 4x5 5x2 3x3 = 39
result 2: 4x5 5x2 3x3 = 39
result 3: 3x5 5x2 3x3 = 34

Thank you!

Does it mean that if i put for example

Yes, you got it correct :)

Thank you bro for your support:)

You may like to see this revision ...

1. that uses functions ...
2. that takes in ('crash safe') string input
3. that validates the input, in a loop, until valid
4. that demos using the same function in different ways, via a 'flag' variable ... also, 'default values'
5. that uses arrays ... so program can be made generic
6. that uses a 'data struct' ... and an array of struct
... and '[i]' and '.' notations
7. that uses Global constants so that the program can be easily revised to handle more than (array of size) 3
etc...

See the added comments and note use of descriptive variable names ... to help 'self document' the code.

Enjoy ...

``````// top3Employees.cpp //

#include <iostream>
#include <string>
#include <sstream> // re. stringstream obj's
#include <cctype> // re. isdigit, toupper

using namespace std;

// can easily change these 2 GLOBAL constants, here,
// to update whole program ...
const int MAX_NUM = 3;
const string POSITIONS[] = { "1st", "2nd", "3rd" } ;

struct Employee
{
string name;
string data;
} ; // <- to tell compiler that the struct end is reached  //

// type 1: to be VALID, string MUST have 4 chars only, each a digit!
// type 0: to be valid, sting must be NON empty ... (default type is 0)
bool isValid( const string& s, int type = 0 )
{
if( type == 1 )
{
if( s.size() == 4 )
{
for( int i = 0; i < 4; ++ i )
{
if( !isdigit( s[i] ) )
{
cout << "\nOnly 0..9 valid ... try again.\n";
return false;
}
}
// else ... if reach here ...
return true;
}
// else ... if reach here ...
cout << "\nMust enter 4 digits ... try again.\n";
return false;
}

// else ... if reach here ... default type
// any non empty string is valid ....
if( s.size() ) return true;

// else ... if reach ehere ...
cout << "\nEmpty string is NOT valid here ... try again.\n";
return false;
}

// takeIn a (Non-Empty) string ...
string takeInString( const string& msg, int type = 0 )
{
string val;
for( ; ; ) // loop forever until 'break' ...
{
cout << msg << flush;
getline( cin, val );
if( isValid( val, type ) ) break;
}

return val;
}

// expects a valid string of 4 digits exactly ...
int calScore( const string& s )
{
return (s-'0')*3 + (s-'0')*2 + (s-'0')*5 ;
}

string toCapsOnAllFirstLetters( const string& s )
{
// call copy ctor... to get copy of s into str
string str(s);

int prev_was_space = 1;
int len = str.size();
for( int i = 0; i < len; ++ i )
{
if( prev_was_space )
str[i] = std::toupper( str[i] );
prev_was_space = isspace( str[i] );
}
return str;
}

// passing in (address of) array of Employee ...
// and size of array
void showResults( const Employee ary[], int size )
{
cout << "Scores for 'top " << MAX_NUM << " dogs' ... \n";

int maxScore = 0;
int maxAtIndex = 0;
for( int i = 0; i < size; ++ i)
{
int score = calScore( ary[i].data );

// find and track 'max' data ...
if( score > maxScore )
{
maxScore = score;
maxAtIndex = i;
}
cout << POSITIONS[i] << ", "
<< toCapsOnAllFirstLetters( ary[i].name )
<< "'s result is: " << score
<< ", and input data was: " <<  ary[i].data
<< endl;
}

// show top ...
cout << "\nThe TOP employee was    :  "
<< toCapsOnAllFirstLetters( ary[maxAtIndex].name )
<< ", \nwith a score of         :  " << maxScore << ", \nand "
<< "input data here was :  " << ary[maxAtIndex].data << endl;
}

int main()
{
Employee top[MAX_NUM]; // get room for 'top guns'

cout << "You will be asked to enter " << MAX_NUM
<< " pairs of data, \n"
<< "first line  : the 4 digit employee data string,\n"
<< "second line : that employee's name ...\n\n";

// ok ... take in values into an array ... in a loop

for( int  i = 0; i < MAX_NUM; ++ i )
{
// form (partial) prompt ... for this employee
ostringstream oss; // call default ctor...
oss << "Enter the " << POSITIONS[i];

// get each (valid) string with prompt ...

top[i].data = takeInString( oss.str() + " result :  ", 1 );
top[i].name = takeInString( oss.str() + " name   :  " );

cout << endl;
}

showResults( top, MAX_NUM );

return 0;
}
``````
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.