I attempted to write my own C++ program: #include<iostream> #include <string> #i
ID: 1798688 • Letter: I
Question
I attempted to write my own C++ program:#include<iostream>
#include <string>
#include < iomanip>
using namespace std;
int main()
{
string name;
double salary;
int F,S,M,H;
F=salary*15%
S=salary*3.5%
M=salary*8.5%
H=salary-75;
cout << "Enter your name: " << endl;
getline(cin, name);
cout << "Enter gross salary: ";
cin >> salary;
cout << endl;
cout << name << endl;
cout << showpoint << setprecision(2);
cout << left << setfill('.') << setw(30) << "Gross Pay: " << right << setfill(' ') << " $" << setw(9) << fixed << salary << endl;
cout << "Press any key to finish" << endl;
cin.ignore(2);
return(0);
}
When I build it, most of it build without issue...it's just the section where my math is at that the build has issues. I am not seeing where I am going wrong. Could someone please clarify my error? Thanks, in advance!
Explanation / Answer
#include <iostream> #include <cstdlib> #include <string> #include <iomanip> using namespace std; int main() { string name; cout << "Enter Employee Name : "; getline(cin, name); double salary; cout << "Enter Gross Pay: "; cin >> salary; double F,S,M,H,N; F=salary*.15; S=salary*.035; M=salary*.085; H=75; N = salary - F -S -M -H; cout << name << endl; cout << showpoint << setprecision(2); cout << left << setfill('.') << setw(30) << "Gross Pay: " << right << setfill(' ') << " $" << setw(9) << fixed << salary << endl; cout << left << setfill('.') << setw(30) << "Federal Tax: " << right << setfill(' ') << " $" << setw(9) << fixed << F << endl; cout << left << setfill('.') << setw(30) << "State Tax: " << right << setfill(' ') << " $" << setw(9) << fixed << S << endl; cout << left << setfill('.') << setw(30) << "Social Sec / Medicare: " << right << setfill(' ') << " $" << setw(9) << fixed << M << endl; cout << left << setfill('.') << setw(30) << "Health Insurance: " << right << setfill(' ') << " $" << setw(9) << fixed << H << endl; cout << left << setfill('.') << setw(30) << "Net Pay: " << right << setfill(' ') << " $" << setw(9) << fixed << N << endl; system ("pause"); return 0; }Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.