hiii!
im backk jajaja
¬¬
not funny, i know.

well, im back with another problem, which is not exactly that, is more a question i wanna do.

This program reads the file, the exage of an employee, the quantity of children and the position that occupies in a company.
If he is a manager, hehas a fixed salary (hours worked by the value that is paid the hour), if ihe is a worker (he receives a fixed salary the first 40 hours and despues 1.5 is paid to him every hour). Also he can be a worker to commission (he earns 500 fixed per month, plus 5.7 % of the sales that he has done) or worker by the piece (he sells just one product, and he is paid the same amout of what he sold)

i can put a max of 100 employees

the program is attached, and also a .doc with the results when i run it, n some screens of the code

// empleados.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
	using namespace std;

	char empleado;
	float sueldo = 0, valor_hora = 0, total;
	float ventas_a_comision = 0, precio_producto_a_destajo;
	int hora = 0, horas_extras = 0;
	int cantidad_vendida;
	
	int totales_empleados = 0;
	int antiguedad;
	int legajo, hijos;
	float a_pagar, sueldo_total = 0;
	

	cout << " Ingrese el codigo del empleado: " << "\n";   // code of employee
	cout << "     1 - GERENTE " << "\n";
	cout << "     2 - OBREROS" << "\n";
	cout << "     3 - POR COMISON" << "\n";
	cout << "     4 - A DESTAJO" << "\n";
	cout << "  5 - salir" << "\n" ;         // 5 to get out
	cin >> empleado;
	cout << "\n" << "\n";

	cout << " Se ingresa un maximo de 100 empleados!" << "\n" << "\n";

	while (empleado != '5')
	{
		for (totales_empleados = 0; ((totales_empleados < 100) && (empleado != '5')); totales_empleados++)          // IS CORRECT TO PUT 2 CONDITIONS HERE???
		{  
			switch (empleado)
			{
				case '1':    // GERENTES!     -----  MANAGERS
					cout << " Ingrese Legajo: ";
					cin >> legajo;       // CODE OF EMPLOYEE

					cout << " Cuantos hijos tiene?? ";
					cin >> hijos;         // KIDS

					cout << " Ingrese cantidad de horas trabajadas: ";         // HOURS WORKED
					cin >> hora;
					cout << "\n";
			
					cout << " De cuanto es el valor de la hora?? " ;            // VALUE OF THE HOUR
					cin >> valor_hora;
					cout << "\n";

					total = ((hora * valor_hora)/4);    // por semana             -- HOW MUCH I PAY HIM FOR A WEEK

					cout << " Ingrese la antiguedad: ";
					cin >> antiguedad;
					cout << "\n";        // EXAGE OF EMPLOYEE

					if ((antiguedad >= 2) && (antiguedad <= 4))
						a_pagar = (total*0.2) + total;
					else if ((antiguedad >= 5) && (antiguedad <= 8))
						a_pagar = (total*0.4) + total;
					else if ((antiguedad >= 9) && (antiguedad <= 12))
						a_pagar = (total*0.6) + total;
					else if ((antiguedad > 13))
						a_pagar = (total*0.8) + total;

					if (hijos > 3)
						sueldo_total = (a_pagar * 1.5) + a_pagar;

					cout << " El legajo del empleado es: " << legajo;
					cout << " Tiene " << hijos << " hijos";
					cout << " El sueldo que va a cobrar es de: " << total << " Pesos aproximadamente x semana";
					cout << " El total a cobrar por mes es de " << sueldo_total;
				break;

				case '2':   // OBREROS!     ------  WORKER ---- THE STRUCTURE IS THE SAME AS THE MANAGER
					cout << " Ingrese Legajo: ";
					cin >> legajo;

					cout << " Cuantos hijos tiene?? ";
					cin >> hijos;

					cout << " Ingrese cantidad de horas trabajadas: ";
					cin >> hora;
					cout << "\n";
			
					cout << " De cuanto es el valor de la hora?? " ;
					cin >> valor_hora;
					cout << "\n";

					if (hora < 40)
						cout << " Se le pagan $" << (hora * valor_hora);
					else
					{
						horas_extras = hora - 40;
						total = horas_extras * (valor_hora * 1.5) + (hora * valor_hora);
					}

					cout << " Ingrese la antiguedad: ";
					cin >> antiguedad;

					if ((antiguedad >= 2) && (antiguedad <= 4))
						a_pagar = (total*0.2) + total;
					else if ((antiguedad >= 5) && (antiguedad <= 8))
						a_pagar = (total*0.4) + total;
					else if ((antiguedad >= 9) && (antiguedad <= 12))
						a_pagar = (total*0.6) + total;
					else if ((antiguedad > 13))
						a_pagar = (total*0.8) + total;

					if (hijos > 3)
						sueldo_total = (a_pagar * 1.5) + a_pagar;

					cout << " El legajo del empleado es: " << legajo << "\n";
					cout << " Tiene " << hijos << " hijos" << "\n";
					cout << " El sueldo que va a cobrar es de: " << (total / 4) << " Pesos aproximadamente x semana" << "\n" << "\n";
					cout << " El total a cobrar por mes es de " << sueldo_total << "\n";
				break;

				case '3':  //POR COMISION!	----- TO COMISSION ---- SAME STRUCTURE
					cout << " Ingrese Legajo: ";
					cin >> legajo;

					cout << " Cuantos hijos tiene?? ";
					cin >> hijos;

					cout << " Se le va a pagar un fijo de 500 $ mensuales" << "\n";
	
					cout << " Ingrese la cantidad de ventas hechas: ";
					cin >> ventas_a_comision;
				
					total = (500 + (((ventas_a_comision * 5.7)/100)*4))/4;

					cout << " Ingrese la antiguedad: ";
					cin >> antiguedad;

					if ((antiguedad >= 2) && (antiguedad <= 4))
						a_pagar = (total*0.2) + total;
					else if ((antiguedad >= 5) && (antiguedad <= 8))
						a_pagar = (total*0.4) + total;
					else if ((antiguedad >= 9) && (antiguedad <= 12))
						a_pagar = (total*0.6) + total;
					else if ((antiguedad > 13))
						a_pagar = (total*0.8) + total;

					if (hijos > 3)
						sueldo_total = (a_pagar * 1.5) + a_pagar;

					cout << " El legajo del empleado es: " << legajo << "\n";
					cout << " Tiene " << hijos << " hijos" << "\n";
			
					cout << " El legajo del empleado es: " << legajo << "\n";
					cout << " Tiene " << hijos << " hijos" << "\n";
					cout << " Va a cobrar: " << total << " Pesos aproximadamente x semana" << "\n" << "\n";
					cout << " El total a cobrar por mes es de " << sueldo_total << "\n";
				break;

				case '4':   // A DESTAJO!     --- SELLIN 1 PRODUCT ---- SAME STRUCTURE AS THE OTHERS
					cout << " Ingrese Legajo: ";
					cin >> legajo;

					cout << " Cuantos hijos tiene?? ";
					cin >> hijos;

					cout << " Ingrese el precio del producto: ";
					cin >> precio_producto_a_destajo;
					cout << "\n";

					cout << " Ingrese la cantidad de cosas que vendio: ";
					cin >> cantidad_vendida;	

					total = (precio_producto_a_destajo * cantidad_vendida)/4;

					cout << " Ingrese la antiguedad: ";
					cin >> antiguedad;

					if ((antiguedad >= 2) && (antiguedad <= 4))
						a_pagar = (total*0.2) + total;
					else if ((antiguedad >= 5) && (antiguedad <= 8))
						a_pagar = (total*0.4) + total;
					else if ((antiguedad >= 9) && (antiguedad <= 12))
						a_pagar = (total*0.6) + total;
					else if ((antiguedad > 13))
						a_pagar = (total*0.8) + total;

					if (hijos > 3)
						sueldo_total = (a_pagar * 1.5) + a_pagar;

					cout << " El legajo del empleado es: " << legajo << "\n";
					cout << " Tiene " << hijos << " hijos" << "\n";
			
					cout << " El legajo del empleado es: " << legajo << "\n";
					cout << " Tiene " << hijos << " hijos" << "\n";

					cout << " Va a cobrar " << total << " aproximadamente x semana" << "\n" << "\n";
					cout << " El total a cobrar por mes es de " << sueldo_total << "\n";
				break;
			}
		}
// IM HAVIN PROBLEMS WITH THIS: DOESNT APPEAR WHEN FINISHED ONE EMPLOYEE. TRIED PUTTIN IT BEFORE CLOSING THE FOR LOOP AND BEFORE CLOSING THE WHILE LOOP, BUT ITS THE SAME! DONT KNOW WHERE TO PUT IT.
		cout << " Ingrese el codigo del empleado: " << "\n"; 
		cout << "     1 - GERENTE " << "\n";
		cout << "     2 - OBREROS" << "\n";
		cout << "     3 - POR COMISON" << "\n";
		cout << "     4 - A DESTAJO" << "\n";
		cout << "  5 - salir" << "\n" ;
		cin >> empleado;
		cout << "\n" << "\n";
	}

	return 0;
}

1. Revise your program logic. You have inner for loop which repeats 100 times without condition. After that you input a new command then repeat this senseless loop again...
2. There is a wonderful thing in C++. It called a function. Define a function to get empleado value from the console, don't copy these lines here, there and everywhere. May be you will get much more clear code...
3. Try to press Ctrl-Z or type not-a-digit after prompt (common misprinting, eh?). See, what heppens. No conversion error checking in your code. It's so pity...
4. Do you think that it's a pleasure to look at this wrapped (tabbed) code in the browser window? See VS Tools|Options|Text Editor|Plain Text|Tabs then switch to Insert Spaces mode...

i just solved myself!
tnks anyways

Be a part of the DaniWeb community

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