hi .........i had a simple question;;;;
i created a simple payrol progrram but there some thing error
here is my code ;;;;;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234
|
#include<iostream.h>
#include<math.h>
#include<string.h>
int main()
{
double nhw,rate,gross,net_income;
double t_deduction,tax,SSS,medicare,bonus;
char name,p;
cout<<"Name :";
cin>> name;
cout<<"\nPosition: Manager (m) Supervisor(s) Employee(e)\n";
cin>> p;
if (p=='m')
{
rate=500;
cout<<"Rate:"<<rate<<endl;
cout<<"No. of days worked";
cin>>nhw;
gross=rate*nhw;
cout<<"Gross:"<<gross<<endl;
if (gross>=8000)
{
bonus=1000;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=5000)
{
bonus=750;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=3000)
{
bonus=500;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross<3000)
{
bonus=0;
cout<<"Bonus:"<<bonus<<endl;
}
else
{
cout<<"________________________________________________";
}
cout<<"Deduction\n";
tax=gross*.15;
cout<<" Tax:"<<tax<<endl;
SSS= gross*.10;
cout<<" SSS:"<<SSS<<endl;
medicare=100;
cout<<" Medicare:"<<medicare<<endl;
t_deduction=tax+SSS+medicare;
cout<<"Total Deduction:"<<t_deduction<<endl;
net_income=gross+bonus-t_deduction;
cout<<"Net income:"<<net_income<<endl;
}
if (p=='s')
{
rate=400;
cout<<"Rate:"<<rate<<endl;
cout<<"No. of days worked";
cin>>nhw;
gross=rate*nhw;
cout<<"Gross:"<<gross<<endl;
if (gross>=8000)
{
bonus=1000;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=5000)
{
bonus=750;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=3000)
{
bonus=500;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross<3000)
{
bonus=0;
cout<<"Bonus:"<<bonus<<endl;
}
else
{
cout<<"________________________________________________";
}
cout<<"Deduction\n";
tax=gross*.15;
cout<<" Tax:"<<tax<<endl;
SSS= gross*.10;
cout<<" SSS:"<<SSS<<endl;
medicare=100;
cout<<" Medicare:"<<medicare<<endl;
t_deduction=tax+SSS+medicare;
cout<<"Total Deduction:"<<t_deduction<<endl;
net_income=gross+bonus-t_deduction;
cout<<"Net income:"<<net_income<<endl;
}
if (p=='m')
{
rate=500;
cout<<"Rate:"<<rate<<endl;
cout<<"No. of days worked";
cin>>nhw;
gross=rate*nhw;
cout<<"Gross:"<<gross<<endl;
if (gross>=8000)
{
bonus=1000;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=5000)
{
bonus=750;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=3000)
{
bonus=500;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross<3000)
{
bonus=0;
cout<<"Bonus:"<<bonus<<endl;
}
else
{
cout<<"________________________________________________";
}
cout<<"Deduction\n";
tax=gross*.15;
cout<<" Tax:"<<tax<<endl;
SSS= gross*.10;
cout<<" SSS:"<<SSS<<endl;
medicare=100;
cout<<" Medicare:"<<medicare<<endl;
t_deduction=tax+SSS+medicare;
cout<<"Total Deduction:"<<t_deduction<<endl;
net_income=gross+bonus-t_deduction;
cout<<"Net income:"<<net_income<<endl;
}
if (p=='m')
{
rate=500;
cout<<"Rate:"<<rate<<endl;
cout<<"No. of days worked";
cin>>nhw;
gross=rate*nhw;
cout<<"Gross:"<<gross<<endl;
if (gross>=8000)
{
bonus=1000;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=5000)
{
bonus=750;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross>=3000)
{
bonus=500;
cout<<"Bonus:"<<bonus<<endl;
}
if (gross<3000)
{
bonus=0;
cout<<"Bonus:"<<bonus<<endl;
}
else
{
cout<<"________________________________________________";
}
cout<<"Deduction\n";
tax=gross*.15;
cout<<" Tax:"<<tax<<endl;
SSS= gross*.10;
cout<<" SSS:"<<SSS<<endl;
medicare=100;
cout<<" Medicare:"<<medicare<<endl;
t_deduction=tax+SSS+medicare;
cout<<"Total Deduction:"<<t_deduction<<endl;
net_income=gross+bonus-t_deduction;
cout<<"Net income:"<<net_income<<endl;
}
return 0;
}
|
butwhen i try to input the name of workers ...
like this..
example;
i input my name "ismael balana"
it has an error...
but when i put ...a single character ..the program dont execute any error...
thats my problem...
anyone...thanks in advance...
char is a type for single character. Try use a string to save names.
Change the include directives to this:
1 2 3 4
|
#include <iostream>
#include <string>
// #include <cmath> // I don't see where you're using this
using namespace std;
|
Change name to string instead of char:
(You need to declare name and p on two different lines)
Change "cin >> name" to this:
This will read the whole line instead of just one word.
or you can use 2 strings for names: firstname and lastname declared like this:
tnx mates...................
hi ropez can you teach my how to use iomanip
tnx.....
Topic archived. No new replies allowed.