| | |
using an if inside a for loop
Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
hi ppl!
im here again
with another problem, which, is more a question about if what im doing is ok.
the thing is i have to do a problem that counts the total of letters sent, the total of packages sent, total of letters and packages sent on the next day priority, on the next day normal, and the total if its sent over 2 days.
also i have to calculate a big total of letters and packages sent (i mean letters + packages in each day) and the percentage of the total of things sent on the next day priority, of the next day normal, and over 2 days.
i already have a code made, my question if its ok to put a for loop in the middle of a chain of ifs:
what i want to do is this: the program must consider the hours in which the people work, so the first for loop would control that [for (hour = hour_begining; (hour > hour_begining) && (hour < hour_final); hour++) ]. now, when it comes to the other two for loops, i dont know if they will stop in any way the ifs, or do i have to write the code differently.
in the code:
peso = weight
dia = day
total_a_pagar = is what i have to pay if i send just one (its calculated only for the packages, if its a letter doesnt matter the weight, its a fixed price)
thanks for the help!!
gispe!!
ps: if anything isnt clear, ask me! and if whole code were necessary ill paste it!!
im here again
with another problem, which, is more a question about if what im doing is ok.the thing is i have to do a problem that counts the total of letters sent, the total of packages sent, total of letters and packages sent on the next day priority, on the next day normal, and the total if its sent over 2 days.
also i have to calculate a big total of letters and packages sent (i mean letters + packages in each day) and the percentage of the total of things sent on the next day priority, of the next day normal, and over 2 days.
i already have a code made, my question if its ok to put a for loop in the middle of a chain of ifs:
C++ Syntax (Toggle Plain Text)
//A GENERAL FOR LOOP WOULD BE HERE if ((peso < 30) && (dia = 7)) cout << " Se le cobraran 8$ " << "\n"; // these 3 are letters, else if ((peso < 30) && (dia = 8)) cout << " Se le cobraran 5$ " << "\n"; else if ((peso < 30) && (dia = 9)) cout << " No esta disponible$ " << "\n"; //ANOTHER PUT A FOR LOOP HERE else if ((peso > 30) && (peso < 1000) && (dia = 7)) // from here to the end, are packages cout << " Se le cobraran 25$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 8)) cout << " Se le cobraran 20$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 9)) cout << " Se le cobraran 15$ " << "\n"; //AND ANOTHER ONE HERE else if((peso > 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; cout << " Y 2$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2) + 2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } else if ((dia = 8) && (peso > 1000)) { cout << " Se le cobraran 20$ " << "\n"; cout << " Y 1.5$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } else if ((dia = 9)&& (peso > 1000)) { cout << " Se le cobraran 15$ " << "\n"; cout << " Y 1$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; }
what i want to do is this: the program must consider the hours in which the people work, so the first for loop would control that [for (hour = hour_begining; (hour > hour_begining) && (hour < hour_final); hour++) ]. now, when it comes to the other two for loops, i dont know if they will stop in any way the ifs, or do i have to write the code differently.
in the code:
peso = weight
dia = day
total_a_pagar = is what i have to pay if i send just one (its calculated only for the packages, if its a letter doesnt matter the weight, its a fixed price)
thanks for the help!!
gispe!!
ps: if anything isnt clear, ask me! and if whole code were necessary ill paste it!!
Last edited by Tekmaven; Jul 24th, 2008 at 3:05 am. Reason: Code tags
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
here is the code
C++ Syntax (Toggle Plain Text)
// caja_paquete_2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> int main(int argc, char* argv[]) { using namespace std; char tipo_servicio, dia; float peso, total_a_pagar = 0, diferencia; // CALCULA PRECIO UNITARIO DE CADA COSA int total_paquete = 0, total_carta = 0; // TOTALES POR TIPO ENTREGA, incializadas int total_dia_sig_prioritario = 0, total_dia_sig_normal = 0, total_2_dias_o_mas = 0; // TOTALES POR DIA, ya inicializadas int totales_de_entregas = 0; // PARA QUE CALCULE EL TOTAL DE ENTREGAS, ya inicializadas float porcentaje_dia_sig_prioritario, porcentaje_dia_siguiente_normal, porcentaje_dos_dias_o_mas; // PORCENTAJES float dinero_recaudado = 0; // TOTAL DINERO RECAUDADO, ya inicializada float hora, hora_fin, hora_inicio; // HORA DEL DIA PARA CARGAR LAS COSAS cout << "Ingrese hora a la que empieza a trabajar (hh.mm): "; cin >> hora_inicio; cout << "\n"; cout << " Ingrese la hora a la que termina de trabajar (hh.mm): "; cin >> hora_fin; cout << "\n"; for (hora = hora_inicio; hora < hora_fin; hora++) { cout << " Ingrese tipo de servicio:" << "\n"; //////// cout << " 1 - Carta" << "\n"; //////// cout << " 2 - Paquete" << "\n"; // cin >> tipo_servicio; // // cout << " Ingrese tipo de entrega: " << "\n"; // primer ingreso cout << " 7 - Dia siguiente prioritario" << "\n"; // de datos cout << " 8 - Dia siguiente normal" << "\n"; // cout << " 9 - Dos dias o mas" << "\n"; // cin >> dia; // // cout << " Ingrese peso EN GRAMOS a enviar: "; //////// cin >> peso; //////// cout << "\n"; if ((peso < 30) && (dia = 7)) // cout << " Se le cobraran 8$ " << "\n"; // else if ((peso < 30) && (dia = 8)) // cout << " Se le cobraran 5$ " << "\n"; else if ((peso < 30) && (dia = 9)) cout << " No esta disponible$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 7)) cout << " Se le cobraran 25$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 8)) cout << " Se le cobraran 20$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 9)) cout << " Se le cobraran 15$ " << "\n"; else if((peso > 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; cout << " Y 2$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2) + 2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } else if ((dia = 8) && (peso > 1000)) { cout << " Se le cobraran 20$ " << "\n"; cout << " Y 1.5$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } else if ((dia = 9)&& (peso > 1000)) { cout << " Se le cobraran 15$ " << "\n"; cout << " Y 1$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } } system ("PAUSE"); return 0; }
Last edited by Tekmaven; Jul 24th, 2008 at 3:07 am. Reason: Code tags
Salem meant you should wrap your code in code tags (the # button on the top, or just type [ code] YOUR CODE HERE [/code], w/o the spaces between '[' and "code").
Do you want the for loop to be part of this conditional:
If so, just wrap the code in curly brackets:
If you meant that the loop is executed regardless of the above conditional, you can also do that, though the else if after it would need to become a regular if:
Do you want the for loop to be part of this conditional:
C++ Syntax (Toggle Plain Text)
else if ((peso > 30) && (peso < 1000) && (dia = 9)) cout << " Se le cobraran 15$ " << "\n"; //for loop only executed if peso is between 30 and 1000 and dia is 9
If so, just wrap the code in curly brackets:
C++ Syntax (Toggle Plain Text)
else if ((peso > 30) && (peso < 1000) && (dia = 9)) { cout << " Se le cobraran 15$ " << "\n"; for(;;) //your loop here } //next else if condition
If you meant that the loop is executed regardless of the above conditional, you can also do that, though the else if after it would need to become a regular if:
C++ Syntax (Toggle Plain Text)
/*else*/if((peso > 1000) && (dia = 7))
Last edited by CoolGamer48; Jul 23rd, 2008 at 6:39 pm.
I'm a student. If my statements seem too absolute, feel free to coat them with "In my opinion..." or "I believe...".
Here's the code in code-tags.
Sorry for "bumping" this thread, but it really gave me a headache to see the code like this and I'm sure it's giving other people a headache too.
Use code tags please! People will be more inclined to help when you do.
c++ Syntax (Toggle Plain Text)
// caja_paquete_2.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> int main(int argc, char* argv[]) { using namespace std; char tipo_servicio, dia; float peso, total_a_pagar = 0, diferencia; // CALCULA PRECIO UNITARIO DE CADA COSA int total_paquete = 0, total_carta = 0; // TOTALES POR TIPO ENTREGA, incializadas int total_dia_sig_prioritario = 0, total_dia_sig_normal = 0, total_2_dias_o_mas = 0; // TOTALES POR DIA, ya inicializadas int totales_de_entregas = 0; // PARA QUE CALCULE EL TOTAL DE ENTREGAS, ya inicializadas float porcentaje_dia_sig_prioritario, porcentaje_dia_siguiente_normal, porcentaje_dos_dias_o_mas; // PORCENTAJES float dinero_recaudado = 0; // TOTAL DINERO RECAUDADO, ya inicializada float hora, hora_fin, hora_inicio; // HORA DEL DIA PARA CARGAR LAS COSAS cout << "Ingrese hora a la que empieza a trabajar (hh.mm): "; cin >> hora_inicio; cout << "\n"; cout << " Ingrese la hora a la que termina de trabajar (hh.mm): "; cin >> hora_fin; cout << "\n"; for (hora = hora_inicio; hora < hora_fin; hora++) { cout << " Ingrese tipo de servicio:" << "\n"; //////// cout << " 1 - Carta" << "\n"; //////// cout << " 2 - Paquete" << "\n"; // cin >> tipo_servicio; // // cout << " Ingrese tipo de entrega: " << "\n"; // primer ingreso cout << " 7 - Dia siguiente prioritario" << "\n"; // de datos cout << " 8 - Dia siguiente normal" << "\n"; // cout << " 9 - Dos dias o mas" << "\n"; // cin >> dia; // // cout << " Ingrese peso EN GRAMOS a enviar: "; //////// cin >> peso; //////// cout << "\n"; if ((peso < 30) && (dia = 7)) // cout << " Se le cobraran 8$ " << "\n"; // else if ((peso < 30) && (dia = 8)) // cout << " Se le cobraran 5$ " << "\n"; else if ((peso < 30) && (dia = 9)) cout << " No esta disponible$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 7)) cout << " Se le cobraran 25$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 8)) cout << " Se le cobraran 20$ " << "\n"; else if ((peso > 30) && (peso < 1000) && (dia = 9)) cout << " Se le cobraran 15$ " << "\n"; else if((peso > 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; cout << " Y 2$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2) + 2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } else if ((dia = 8) && (peso > 1000)) { cout << " Se le cobraran 20$ " << "\n"; cout << " Y 1.5$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } else if ((dia = 9)&& (peso > 1000)) { cout << " Se le cobraran 15$ " << "\n"; cout << " Y 1$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; } } system ("PAUSE"); return 0; }
Sorry for "bumping" this thread, but it really gave me a headache to see the code like this and I'm sure it's giving other people a headache too.
Use code tags please! People will be more inclined to help when you do.
Last edited by Alex Edwards; Jul 23rd, 2008 at 8:07 pm.
•
•
Join Date: Jan 2008
Posts: 3,832
Reputation:
Solved Threads: 501
•
•
•
•
so, u mean that i should put the for inside the if, n wont modify the ifs instructions?
cuz i have to count the letters sent every day, and then sum it up
Please don't use leet-speak. He's asking whether the for-loop should always be executed, regardless of whether the if-condition is true. If it should always be executed, then don't put the for-loop inside the if-statement. If the for-loop should only be executed if the the if-condition is true, then put the for-loop inside the if-statement's brackets.
I don't understand what you mean by this sentence, the red part in particular.
•
•
•
•
so, u mean that i should put the for inside the if, n wont modify the ifs instructions?
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
well, im back here: same program.
i made some modifications n now runs, but the thing is that it puts on screen same message indefinitely.
it reads the hours it worked, what i want to send (package or letter), and the day i want to send it. n then it returns the cost (indefinitely).
there is the code attached, if u want to try it
#
i made some modifications n now runs, but the thing is that it puts on screen same message indefinitely.
it reads the hours it worked, what i want to send (package or letter), and the day i want to send it. n then it returns the cost (indefinitely).
there is the code attached, if u want to try it
#
c++ Syntax (Toggle Plain Text)
// cartas_paquetes_v3.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { using namespace std; char dia, tipo_servicio, horario_trabajo; float peso, total_a_pagar = 0, diferencia; // CALCULA PRECIO UNITARIO DE CADA COSA int total_paquete = 0, total_carta = 0; // TOTALES POR TIPO ENTREGA, incializadas int total_dia_sig_prioritario = 0, total_dia_sig_normal = 0, total_2_dias_o_mas = 0; // TOTALES POR DIA, ya inicializadas int total_dia_siguiente_prioritario_p = 0, total_dia_siguiente_prioritario_c = 0; // TOTALES SIG. PRIO C Y P , inicializadas int total_dia_siguiente_prioritario_p1 = 0, total_dia_siguiente_normal_p1 = 0, total_dos_dias_o_mas_p1 = 0; // para paquetes mayores a 1000, inicializadas int total_dia_siguiente_normal_p = 0, total_dia_siguiente_normal_c = 0; // TOTAL DIA SIG NORMAL, inicializadas int total_dos_dias_o_mas_p = 0; // TOTAL DOS DIAS O MAS, inicializadas int totales_de_entregas = 0; // PARA QUE CALCULE EL TOTAL DE ENTREGAS, ya inicializadas float porcentaje_dia_sig_prioritario, porcentaje_dia_siguiente_normal, porcentaje_dos_dias_o_mas; // PORCENTAJES float dinero_recaudado = 0; // TOTAL DINERO RECAUDADO, ya inicializada float hora = 0, hora_fin, hora_inicio; // HORA DEL DIA PARA CARGAR LAS COSAS int tp, tc; // CONTADORES tp, para paquete tc, para carta cout << "Ingrese hora a la que empieza a trabajar (hh.mm): "; cin >> hora_inicio; cout << "\n"; cout << " Ingrese la hora a la que termina de trabajar (hh.mm): "; cin >> hora_fin; cout << "\n"; for (hora = hora_inicio; hora < hora_fin; hora++) { cout << " Ingrese tipo de servicio:" << "\n"; cout << " 1 - Carta" << "\n"; cout << " 2 - Paquete" << "\n"; cin >> tipo_servicio; cout << " Ingrese tipo de entrega: " << "\n"; cout << " 7 - Dia siguiente prioritario" << "\n"; cout << " 8 - Dia siguiente normal" << "\n"; cout << " 9 - Dos dias o mas" << "\n"; cin >> dia; cout << " Ingrese peso EN GRAMOS a enviar: "; cin >> peso; cout << "\n"; for (tc = 1; tipo_servicio = 1; tc++) { if (dia = 7) { cout << " Se le cobraran 8$ " << "\n"; total_dia_siguiente_prioritario_c += 1; } else if (dia = 8) { cout << " Se le cobraran 5$ " << "\n"; total_dia_siguiente_normal_c += 1; } else if (dia = 9) cout << " No esta disponible$ " << "\n"; } for (tp = 1; tipo_servicio = 2; tp++) { if ((peso > 30) && (peso < 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; total_dia_siguiente_prioritario_p += 1; } else if ((peso > 30) && (peso < 1000) && (dia = 8)) { cout << " Se le cobraran 20$ " << "\n"; total_dia_siguiente_normal_p += 1; } else if ((peso > 30) && (peso < 1000) && (dia = 9)) { cout << " Se le cobraran 15$ " << "\n"; total_dos_dias_o_mas_p += 1; } else if((peso > 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; cout << " Y 2$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2) + 2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; total_dia_siguiente_prioritario_p1 += 1; } else if ((dia = 8) && (peso > 1000)) { cout << " Se le cobraran 20$ " << "\n"; cout << " Y 1.5$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; total_dia_siguiente_normal_p1 += 1; } else if ((dia = 9)&& (peso > 1000)) { cout << " Se le cobraran 15$ " << "\n"; cout << " Y 1$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; total_dos_dias_o_mas_p1 += 1; } } } total_paquete = total_dia_siguiente_normal_p + total_dos_dias_o_mas_p + total_dia_siguiente_prioritario_p; // TOTAL PAQUETE total_carta = total_dia_siguiente_prioritario_c + total_dia_siguiente_normal_c; //TOTAL CARTAS total_dia_sig_prioritario = total_dia_siguiente_prioritario_p + total_dia_siguiente_prioritario_c; //TOTAL DIA SIGUIENTE PRIORITARIO total_dia_sig_normal = total_dia_siguiente_normal_p + total_dia_siguiente_normal_c; // TOTAL DIA SIGUIENTE NORMAL total_2_dias_o_mas = total_dos_dias_o_mas_p; // TOTAL DOS DIAS O MAS totales_de_entregas = total_paquete + total_carta; //TOTAL DINERO RECAUDADO // dinero_recaudado = ; system ("PAUSE"); return 0; }
Last edited by Tekmaven; Jul 24th, 2008 at 3:08 am. Reason: Code tags
•
•
Join Date: Jul 2008
Posts: 60
Reputation:
Solved Threads: 0
C++ Syntax (Toggle Plain Text)
// cartas_paquetes_v3.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> int _tmain(int argc, _TCHAR* argv[]) { using namespace std; char dia, tipo_servicio, horario_trabajo; float peso, total_a_pagar = 0, diferencia; // CALCULA PRECIO UNITARIO DE CADA COSA int total_paquete = 0, total_carta = 0; // TOTALES POR TIPO ENTREGA, incializadas int total_dia_sig_prioritario = 0, total_dia_sig_normal = 0, total_2_dias_o_mas = 0; // TOTALES POR DIA, ya inicializadas int total_dia_siguiente_prioritario_p = 0, total_dia_siguiente_prioritario_c = 0; // TOTALES SIG. PRIO C Y P , inicializadas int total_dia_siguiente_prioritario_p1 = 0, total_dia_siguiente_normal_p1 = 0, total_dos_dias_o_mas_p1 = 0; // para paquetes mayores a 1000, inicializadas int total_dia_siguiente_normal_p = 0, total_dia_siguiente_normal_c = 0; // TOTAL DIA SIG NORMAL, inicializadas int total_dos_dias_o_mas_p = 0; // TOTAL DOS DIAS O MAS, inicializadas int totales_de_entregas = 0; // PARA QUE CALCULE EL TOTAL DE ENTREGAS, ya inicializadas float porcentaje_dia_sig_prioritario, porcentaje_dia_siguiente_normal, porcentaje_dos_dias_o_mas; // PORCENTAJES float dinero_recaudado = 0; // TOTAL DINERO RECAUDADO, ya inicializada float hora = 0, hora_fin, hora_inicio; // HORA DEL DIA PARA CARGAR LAS COSAS int tp, tc; // CONTADORES tp, para paquete tc, para carta cout << "Ingrese hora a la que empieza a trabajar (hh.mm): "; cin >> hora_inicio; cout << "\n"; cout << " Ingrese la hora a la que termina de trabajar (hh.mm): "; cin >> hora_fin; cout << "\n"; for (hora = hora_inicio; hora < hora_fin; hora++) { cout << " Ingrese tipo de servicio:" << "\n"; cout << " 1 - Carta" << "\n"; cout << " 2 - Paquete" << "\n"; cin >> tipo_servicio; cout << " Ingrese tipo de entrega: " << "\n"; cout << " 7 - Dia siguiente prioritario" << "\n"; cout << " 8 - Dia siguiente normal" << "\n"; cout << " 9 - Dos dias o mas" << "\n"; cin >> dia; cout << " Ingrese peso EN GRAMOS a enviar: "; cin >> peso; cout << "\n"; for (tc = 1; tipo_servicio = 1; tc++) { if (dia = 7) { cout << " Se le cobraran 8$ " << "\n"; total_dia_siguiente_prioritario_c += 1; } else if (dia = 8) { cout << " Se le cobraran 5$ " << "\n"; total_dia_siguiente_normal_c += 1; } else if (dia = 9) cout << " No esta disponible$ " << "\n"; } for (tp = 1; tipo_servicio = 2; tp++) { if ((peso > 30) && (peso < 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; total_dia_siguiente_prioritario_p += 1; } else if ((peso > 30) && (peso < 1000) && (dia = 8)) { cout << " Se le cobraran 20$ " << "\n"; total_dia_siguiente_normal_p += 1; } else if ((peso > 30) && (peso < 1000) && (dia = 9)) { cout << " Se le cobraran 15$ " << "\n"; total_dos_dias_o_mas_p += 1; } else if((peso > 1000) && (dia = 7)) { cout << " Se le cobraran 25$ " << "\n"; cout << " Y 2$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2) + 2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; total_dia_siguiente_prioritario_p1 += 1; } else if ((dia = 8) && (peso > 1000)) { cout << " Se le cobraran 20$ " << "\n"; cout << " Y 1.5$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; total_dia_siguiente_normal_p1 += 1; } else if ((dia = 9)&& (peso > 1000)) { cout << " Se le cobraran 15$ " << "\n"; cout << " Y 1$ adicionales por cada 500 gr de màs" << "\n"; diferencia = ((peso-1000) / 500); total_a_pagar = (25 + ((diferencia *2)+2)); cout << " Se le cobraran" << total_a_pagar << " $ en total" << "\n"; total_dos_dias_o_mas_p1 += 1; } } } total_paquete = total_dia_siguiente_normal_p + total_dos_dias_o_mas_p + total_dia_siguiente_prioritario_p; // TOTAL PAQUETE total_carta = total_dia_siguiente_prioritario_c + total_dia_siguiente_normal_c; //TOTAL CARTAS total_dia_sig_prioritario = total_dia_siguiente_prioritario_p + total_dia_siguiente_prioritario_c; //TOTAL DIA SIGUIENTE PRIORITARIO total_dia_sig_normal = total_dia_siguiente_normal_p + total_dia_siguiente_normal_c; // TOTAL DIA SIGUIENTE NORMAL total_2_dias_o_mas = total_dos_dias_o_mas_p; // TOTAL DOS DIAS O MAS totales_de_entregas = total_paquete + total_carta; //TOTAL DINERO RECAUDADO // dinero_recaudado = ; system ("PAUSE"); return 0; }
Last edited by Tekmaven; Jul 24th, 2008 at 3:09 am. Reason: Code tags
![]() |
Similar Threads
- automatically insert code after every read and write inside a loop in a c program (Computer Science)
- Can't get loop to work properly (C++)
- For loop (PHP)
- do while loop - not stopping!! (Java)
- How to loop inside application via script (Shell Scripting)
- while loop question (Python)
- Need help with string loop (C)
- need help with while loop (Java)
- problem creating a for loop for an array (C++)
- loop problem (C++)
Other Threads in the C++ Forum
- Previous Thread: Dialog resource error
- Next Thread: making a simple c++ game
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bmp c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph gui homeworkhelp iamthwee ifstream image input int java lib library list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference rpg simple sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets






