hi ppl
im back here with a kinda major problem
thing is i made this program for some company that sends letters or packages, and has 3 types of services: to send it the next day with priority, the next day but whithout the priority, or to send it in 2 or more.
the letters must weight 30 gr as max, if its more, then is a package.
packages are also divided: if it weights less than 1000 gr it has a fixed cost, that depends on the day i send it, and if it weights more, i have to add some extra money, also depending on the day.
the problem is when the program just began: i validate if the user wants to start or not. it doesnt take the 0 to go out. if i put the '0', doesnt do anything, and gives an error, if i dont, the program keeps going as if the while wasnt there.
in the word attached, is the error that appear.
hope the explanation is helpfull :S
dont know what it is :S
// cartas_y_paquetes.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
int main(int argc, char* argv[])
{
using namespace std;
char empezar;
char a_enviar, dia;
float peso;
int total_dsp_c = 0, costo_dsp_c = 0;
int total_dsn_c = 0, costo_dsn_c = 0;
int total_dsp_p = 0, costo_dsp_p = 0;
int total_dsn_p = 0, costo_dsn_p = 0;
int total_dos_d_p = 0, costo_dos_d_p = 0;
int total_dsp_p1000 = 0, costo_dsp_p1000 = 0;
int total_dsn_p1000 = 0, costo_dsn_p1000 = 0;
int total_dos_d_p1000 = 0, costo_dos_d_p1000 = 0;
int totales_dsp, totales_dsn, totales_dos_d;
int recaudado_dsp, recaudado_dsn, recaudado_dos_d;
int entregas_totales, costo_total;
int porc_dsp, porc_dsn, porc_dos_d;
cout << " Empezar?? " << "\n"; // TO START
cout << " 1 - SI" << "\n";
cout << " 0 - NO" << "\n";
cin >> empezar;
cout << "\n" << "\n";
while (empezar != '0') // IF I PUT THIS WITH '' DOESNT WORK. IF DONT, DOESNT TAKE IT
{
cout << " Ingrese lo que va a enviar: " << "\n";
cout << " 3 - Carta" << "\n";
cout << " 4 - Paquete " << "\n";
cin >> a_enviar;
cout << "\n" << "\n";
cout << " Ingrese dia a enviar: " << "\n";
cout << " 6 - Dia Siguiente prioritario" << "\n";
cout << " 7 - Dia siguiente normal" << "\n";
cout << " 8 - Dos dias o mas" << "\n";
cin >> dia;
cout << "\n" << "\n";
cout << " Ingrese peso del paquete: " << "\n";
cin >> peso;
cout << "\n" << "\n";
if (a_enviar == '3')
{
if(dia == '7')
{
costo_dsp_c += 8;
total_dsp_c += 1;
}
else if (dia == '8')
{
costo_dsn_c += 5;
total_dsn_c += 1;
}
else if (dia == '9')
cout << " NO DISPONIBLE" << "\n";
}
if ((a_enviar == '4') && (peso <= 1000))
{
if (dia == '6')
{
costo_dsp_p += 25;
total_dsp_p +=1;
}
else if (dia == '7')
{
costo_dsn_p += 20;
total_dsn_p +=1;
}
else if (dia == '8')
{
costo_dos_d_p += 15;
total_dos_d_p +=1;
}
}
if ((a_enviar == '4') && (peso > 1000))
{
if (dia == '6')
{
costo_dsp_p1000 += 25 + (((peso-1000)/500)+2);
total_dsp_p1000 +=1;
}
else if (dia == '7')
{
costo_dsn_p1000 += 20 + (((peso-1000)/500)+1.5);
total_dsn_p1000 +=1;
}
else if (dia == '8')
{
costo_dos_d_p1000 += 15 + (((peso-1000)/500)+1);
total_dos_d_p1000 +=1;
}
}
cout << " Seguir??" << "\n";
cout << " 1 - SI" << "\n";
cout << " 0 - NO" << "\n";
cin >> empezar;
cout << "\n" << "\n";
}
// CALCULATE TOTALS
totales_dsp = total_dsp_c + total_dsp_p + total_dsp_p1000;
totales_dsn = total_dsn_c + total_dsn_p + total_dsn_p1000;
totales_dos_d = total_dos_d_p + total_dos_d_p1000;
entregas_totales = totales_dsp + totales_dsn + totales_dos_d;
recaudado_dsp = costo_dsp_c + costo_dsp_p + costo_dsp_p1000;
recaudado_dsn = costo_dsn_c + costo_dsn_p + costo_dsn_p1000;
recaudado_dos_d = costo_dos_d_p + costo_dos_d_p1000;
costo_total = recaudado_dsp + recaudado_dsn + recaudado_dos_d;
porc_dsp = (totales_dsp * 100) / entregas_totales;
porc_dsn = (totales_dsn * 100) / entregas_totales;
porc_dos_d = (totales_dos_d * 100) / entregas_totales;
// SHOW ALL TOTALS
cout << " --- " << "\n";
cout << " --- " << "\n";
cout << " " << "\n";
cout << " Las entregas totales hechas al dia siguiente prioritario fueron: " << totales_dsp << "\n";
cout << " Las entregas hechas al dia siguiente normal fueron:" << recaudado_dsn << "\n";
cout << " Las entregas realizadas a los dos dias o mas son: " << totales_dos_d << "\n";
cout << " " << "\n";
cout << " --- " << "\n";
cout << " " << "\n";
cout << " Lo recaudado en el dia siguiente prioritario es de " << recaudado_dsp << "\n";
cout << " Lo que se recaudo por enviar en el dia siguiente normal fue de " << recaudado_dsn << "\n";
cout << " Lo recaudado a los dos dias o mas fue de " << recaudado_dos_d << "\n";
cout << " " << "\n";
cout << " --- " << "\n";
cout << " " << "\n";
cout << " El porcentaje de las ventas del dia siguiente prioritario es de " << porc_dsp << "\n";
cout << " El porcentaje de las ventas del dia siguiente normal es de " << porc_dsn << "\n";
cout << " El porcentaje de las ventas de dos dias o mas es de " << porc_dos_d << "\n";
cout << " " << "\n";
cout << " --- " << "\n";
cout << " --- " << "\n";
system ("PAUSE");
return 0;
}