עבור לתוכן

עזרה ב C++

Featured Replies

פורסם

עשיתי איזה תוכנה ויש לי בעיה קטנה

התוצאה שהתוכנה מציגה לי הוא בצורה הבאה 9.25596e+08

למה זה??

איך אני פותר את זה

המשתנה שמאכסן את המספר הזה מוגדר כ FLOAT

בבקשה תעזרו לי אני צריך להגיש את זה להיום

תודה לעוזרים

פורסם

גם זה מספר...

בכל מקרה, תכתוב כאן את הקוד של התוכניות ונוכל לעזור לך בצורה טובה יותר

ומה פתאום אתה צריך להגיש היום משהו?! :s05:

פורסם
  • מחבר

אני לא לומד בארץ

יש לקוד איזה אלף ומשהו שורות

אבל נגיד שזה ככה (רק הרבה יותר מסובך)

float d,a,b,c

d=a+b+c

cout << d

פורסם

עם החלק הזה אני לא ממש רואה בעיה כלשהי (חוץ מהעובדה שלא כתבת ";", אבל לא נהיה קטנוניים  ;))

תצטרך לכתוב יותר בפירוט

איך הצבת את המספרים בשאר המשתנים?

פורסם
  • מחבר

אוקי זה נורא קשה להעתיק רק חלק מסוים

וזה גם בספרדית (מה שלא קוד)

אבל אני ינסה

הנה חלק מהתוכנה

למשתנה הבעייתי קוראים

sneto

וכמו שאתה רואה בשורה המודגשת באדום המשתנה הזה שווה לסכום של כמה משתנים נוספים שכולם מוגדרים תחת אותו סוג

FLOAT

#include <iostream>

#include<fstream.h>

using std::endl;

void main (void)

{

int opcion,ht,seguir=1;

float pago,salario,ssocial,seduc,IR,dduc,sneto;

char nombre[20],ced[15],apellido[20], menu='m',deduc='n', data[300];

ofstream fout;

ifstream fin;

while (menu=='m')

{

system("CLS");

cout<<"\t\t\t PLANILLA\n\n\n\n"

<<"\t\t\t\t\t\thecho por TAL LEVY\n"

<<"\t\t\t\t\t\tCED:E-8-89925\n\n\n\n\n"

<<"1.Crear una nueva planilla y introducir el primer registro\n"

<<"2.Ver registros de la planilla existente\n"

<<"3.introducir nuevo registro a una planilla existente\n"

<<"4.Salir del programa\n\n\n"

<<"Escoge Una Opcion: ";

cin>>opcion;

switch(opcion)

{

case 1:

fout.open("planilla.txt", ios :: out | ios :: trunc);

seguir=1;

while (seguir==1)

{

system("CLS");

cout<<"\t\t\tREGISTROS DE PLANILLA\n\n\n\n";

fout <<"\nRegistro"<<endl;

cout<<"\nNombre-> ";

cin>>nombre;

cout<<"\nApellido-> ";

cin>>apellido;

fout <<"\nNombre Completo: "<<nombre<<" "<<apellido<<endl<<"\n";

cout<<"\nCedula-> ";

cin>>ced;

fout <<"Cedula: "<<ced<<endl<<"\n";

cout<<"\nHoras Trabajadas-> ";

cin>>ht;

cout<<"\nPago basico por Hora-> ";

cin>>pago;

if (ht<=40)

salario=ht*pago;

else

if (ht>40 && ht<=50)

salario=40*pago +(ht-40)*(pago*1.10);

else

salario=40*pago + 10*(pago*1.10)+ (ht-50)*(pago*1.15);

cout<<"\nEl salario bruto de "<< nombre<<" "<<apellido<<" es de "<< salario ;

//Deducciones

ssocial=salario*0.0725;

seduc=salario*0.0125;

if (salario<800)

IR=0;

else

if (salario>800)

IR=salario*0.15;

else

if (salario>1000)

IR=salario*0.16;

else

if (salario>1200)

IR=salario*0.17;

else

if (salario>1300)

IR=salario*0.18;

else

if (salario>1500)

IR=salario*0.20;

cout<<"\n\n Algunas deducciones externas? s/n: ";

cin>>deduc;

if (deduc=='s')

{

do

{

cout<<"\nIntroduzca la deduccion = ";

cin>>dduc;

cout<<"\n Algunas deducciones externas? s/n: ";

cin>>deduc;

} while (deduc=='s');

}

sneto=salario-(ssocial+seduc+IR+dduc);

cout<<"\nSeguro Social= "<<ssocial;

cout<<"\nSeguro Educativo= "<<seduc;

cout<<"\nImpuesto Sobre la Renta= "<<IR;

cout<<"\nEl salario neto de "<< nombre<<" "<<apellido<<" es "<< sneto ; fout <<"Salario Neto: "<<sneto<<endl<<"\n";

fout <<"- - - - - - - - - - - - - -\n"<<endl;

cout<<"\n\nDesea Continuar? Marque 1 para seguir, 0 para el menu principal: ";

cin>>seguir;

}

fout.close();

break;

case 2:

seguir=1;

while (seguir==1)

{

system("CLS");

cout<<"\t\t\tPLANILLA\n\n\n\n";

fin.open("planilla.txt", ios :: in);

fin.getline(data,300);

while (!fin.eof( ))

{

cout<<data<<"\n"<<endl;

fin.getline(data,300);

}

fin.close( );

cout<<"\n\nMarque 0 para el menu principal: ";

cin>>seguir;

}

break;

case 3:

fout.open("planilla.txt", ios :: out | ios :: app);

seguir=1;

while (seguir==1)

{

system("CLS");

cout<<"\t\t\tNUEVO ANEXO\n\n\n\n";

fout <<"\nRegistro "<<endl;

cout<<"\nNombre: ";

cin>>nombre;

cout<<"\nApellido: ";

cin>>apellido;

fout <<"\nNombre Completo: "<<nombre<<" "<<apellido<<endl<<"\n";

cout<<"\nCedula: ";

cin>>ced;

fout <<"Cedula: "<<ced<<endl<<"\n";

cout<<"\nHoras Trabajadas: ";

cin>>ht;

cout<<"\nPago x Hora: ";

cin>>pago;

if (ht<=40)

salario=ht*pago;

else

if (ht>40 && ht<=50)

salario=40*pago +(ht-40)*(pago*1.10);

else

salario=40*pago + 10*(pago*1.10)+ (ht-50)*(pago*1.15);

cout<<"\nEl salario bruto de "<< nombre<<" "<<apellido<<" es "<< salario ;

//Deducciones

ssocial=salario*0.0725;

seduc=salario*0.0125;

if (salario<800)

IR=0;

else

if (salario>800)

IR=salario*0.15;

else

if (salario>1000)

IR=salario*0.16;

else

if (salario>1200)

IR=salario*0.17;

else

if (salario>1300)

IR=salario*0.18;

else

if (salario>1500)

IR=salario*0.20;

cout<<"\n\nTiene algunas deducciones extras? s/n: ";

cin>>deduc;

if (deduc=='s')

{

do

{

cout<<"\nIntroduzca la deduccion por favor = ";

cin>>dduc;

cout<<"\nTiene algunas deducciones extras? s/n: ";

cin>>deduc;

} while (deduc=='s');

}

sneto=salario-(ssocial+seduc+IR+dduc);

cout<<"\nSeguro Social= "<<ssocial;

cout<<"\nSeguro Educativo= "<<seduc;

cout<<"\nImpuesto Sobre la Renta= "<<IR;

cout<<"\nEl salario neto de "<< nombre<<" "<<apellido<<" es "<< sneto ; fout <<"Salario Neto: "<<sneto<<endl<<"\n";

fout <<"- - - - - - - - - - - - - -\n"<<endl;

cout<<"\n\nDesea Continuar? Marque 1 para seguir, 0 para el menu principal: ";

cin>>seguir;

}

fout.close();

break;

case 4:

return;

break;

}

}

}

פורסם
  • מחבר

כן זה ספרדית

וזה לא עבד לי

הוספתי את הספריה הזאת

וה SETW לא עזר

הוספתי את ה SETW  בשורות הכתומות

ולא קרה כלום

אני חושב שזה לא קשור בצורה שהוא מציג אותו

כי התוצאה שהוא מציג בכלל לא קשורה לתוצאה שאמורה לצאת

פורסם

חשבת להוסיף (float( לפני השם משתנה שלך כשאתה מדפיס אותו?

פורסם
  • מחבר

תודה רבה לכל העוזרים

מצאתי כבר את הפתרון

זה היה איזה משתנה מזורגג שהיה חסר

בקיצור הגשתי את הפרויקט היום והפרופסור אהב את זה :jump: :jump:

שוב תתודה רבה לכולםםם

:yelclap:

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים