Merhabalar,
Yazdigim programda do post test yapamaya calistim ama nedense olmadi.inputlari girebiliyor hesaplama yapiyor ama tekrar basa donmuyor. Sikinti nerdedir acep.,
Tesekkurler
-----------------
// in this program we will calculate payments for employee.We will take employee numbers,hours worked ,hourly payment rate,state tax ,federal tax and fica holdings from user and we are going$
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//employeenumber,hoursworked,hourlypay,gross,statetax,federaltax, federal...
int empnu,hw; //this is for employee numbers and for hours worked
double spay, fpay, ficapay, netpay; //this type for fica holdings and taxes
float hp, gross, statetax, federaltax, fica; //they will be float characters
cout << "What is the employee number: ";
cin >> empnu;
do
{
//inputs for the program
cout << "How many hours worked: ";
cin >> hw;
cout << "What is the hourly pay rate: ";
cin >> hp;
cout << "Enter percentage to be withheld for state income tax in decimal form: ";
cin >> statetax;
cout << "Enter percentage to be withheld for federal income tax in decimal form: ";
cin >> federaltax;
cout << "Enter percentage to be withheld for FICA in decimal form: ";
cin >> fica;
//calculations
gross = hw * hp;
spay = gross * statetax;
fpay = gross * federaltax;
ficapay = gross * fica;
netpay = gross - spay - fpay - ficapay;
while (hw < 0 || hp < 0 || statetax < 0 || federaltax < 0 || fica < 0)
{cout << " " << endl;
cout << "Re-enter data must be greater than 0: " << endl;
cout << "Enter the employee number: ";
cin >> empnu;
cout << "Enter hours worked: ";
cin >> hw;
cout << "Enter hourly pay rate: ";
cin >> hp;
cout << "Enter percentage to be withheld for state income tax: ";
cin >> statetax;
cout << "Enter percentage to be withheld for federal income tax: ";
cin >> federaltax;
cout << "Enter percentage to be withheld for FICA: ";
cin >> fica;
gross = hw * hp;
spay = gross * statetax;
fpay = gross * federaltax;
ficapay = gross * fica;
netpay = gross - spay - fpay - ficapay;
}//display
cout << "Payroll Report:\n\n";
cout << "The Employee Number is: " << empnu << endl;
cout << "You gross pay is: $" << gross << endl;
cout << "Your state tax withheld is: $" << spay << endl;
cout << "Your federal tax withheld is: $" << fpay << endl;
cout << "Your FICA withholdings is: $" << ficapay << endl;
cout << "Your total netpay is: $" << netpay << endl;
}
while(empnu == 0);
return 0;
}
Yazdigim programda do post test yapamaya calistim ama nedense olmadi.inputlari girebiliyor hesaplama yapiyor ama tekrar basa donmuyor. Sikinti nerdedir acep.,
Tesekkurler
-----------------
// in this program we will calculate payments for employee.We will take employee numbers,hours worked ,hourly payment rate,state tax ,federal tax and fica holdings from user and we are going$
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//employeenumber,hoursworked,hourlypay,gross,statetax,federaltax, federal...
int empnu,hw; //this is for employee numbers and for hours worked
double spay, fpay, ficapay, netpay; //this type for fica holdings and taxes
float hp, gross, statetax, federaltax, fica; //they will be float characters
cout << "What is the employee number: ";
cin >> empnu;
do
{
//inputs for the program
cout << "How many hours worked: ";
cin >> hw;
cout << "What is the hourly pay rate: ";
cin >> hp;
cout << "Enter percentage to be withheld for state income tax in decimal form: ";
cin >> statetax;
cout << "Enter percentage to be withheld for federal income tax in decimal form: ";
cin >> federaltax;
cout << "Enter percentage to be withheld for FICA in decimal form: ";
cin >> fica;
//calculations
gross = hw * hp;
spay = gross * statetax;
fpay = gross * federaltax;
ficapay = gross * fica;
netpay = gross - spay - fpay - ficapay;
while (hw < 0 || hp < 0 || statetax < 0 || federaltax < 0 || fica < 0)
{cout << " " << endl;
cout << "Re-enter data must be greater than 0: " << endl;
cout << "Enter the employee number: ";
cin >> empnu;
cout << "Enter hours worked: ";
cin >> hw;
cout << "Enter hourly pay rate: ";
cin >> hp;
cout << "Enter percentage to be withheld for state income tax: ";
cin >> statetax;
cout << "Enter percentage to be withheld for federal income tax: ";
cin >> federaltax;
cout << "Enter percentage to be withheld for FICA: ";
cin >> fica;
gross = hw * hp;
spay = gross * statetax;
fpay = gross * federaltax;
ficapay = gross * fica;
netpay = gross - spay - fpay - ficapay;
}//display
cout << "Payroll Report:\n\n";
cout << "The Employee Number is: " << empnu << endl;
cout << "You gross pay is: $" << gross << endl;
cout << "Your state tax withheld is: $" << spay << endl;
cout << "Your federal tax withheld is: $" << fpay << endl;
cout << "Your FICA withholdings is: $" << ficapay << endl;
cout << "Your total netpay is: $" << netpay << endl;
}
while(empnu == 0);
return 0;
}

do {
...
} while (empnu == 0);
yazmışsınız. Employee number olarak 0 girmediğiniz sürece geri dönmez.
metalik


yazdığınız do while döngüsünde empnu 0'sa başa dönmek üzere tasarlanmış bir döngü mevcut. bir de anlamadığım bir nokta var. en başta çalışan sayısını alıyorsunuz daha sonra, bundan devam ederken aynı çalışan sayısını değiştirip hesap yapıyorsunuz. acaba 2. çalışan sayısı olarak koyduğunuz çalışan'ın numarası mı olacaktı? başta orda tekrar çalışan sayısını doldurduğunuz için döngü tekrar başlamaz (0 demeniz hariç tabi)
advice duck

1