Hello i need help with the spacing of my program C This is m
Hello, i need help with the spacing of my program.
C++ This is my code and the spacing instructions are below.
/* Ali Hijazi
Monday Lab*/
#include
#include
#include
using namespace std;
int main() {
string name1;
int yr1;
double sal1;
string name2;
int yr2;
double sal2;
 
cout << \"Enter employee name:\ \";
getline(cin, name1);
cout << \"Enter years in Service:\ \";
cin >> yr1;
cout << \"Enter Salary:\ \";
cin >> sal1;
cout << \"Enter employee name:\ \";
cin.ignore(1);
getline(cin, name2);
cout << \"Enter years in service\ \";
cin >> yr2;
cout << \"Enter Salary\ \";
cin >> sal2;
 
 
cout << fixed << setprecision(2);
cout << \" \ \";
cout << \" \ \";
cout << \" \ \";
cout << \"Employee data\ \";
 
 
cout <
 
return 0;
}
Formatting of the output: The names and the name label should be left justified within 20 total spaces. The years and the year label should be right justified within 5 total spaces. The salaries and the salary label should be right justified within 12total spaces. The average label should be left justified on a new line. The average year value should show one decimal place and be aligned with the years. The average salary should show two decimal places and be aligned with the salaries. Here is a sample run: Enter employee name Joe Thomas Enter years of service 7 salary: 35000 Enter employee name Ed K. Johnson Enter years of service 12 Enter salary: 9876.54 Employee data. Years Salary Name 35000.00 Joe Thomas 9876.54 Ed K. Johnson 12 9.5 22438.27 AverageSolution
#include<bits/stdc++.h>
 using namespace std;
 int main() {
 string name1;
 int yr1;
 double sal1;
 string name2;
 int yr2;
 double sal2;
 
 cout << \"Enter employee name: \";
   
 getline(cin, name1);
   
 cout << \"Enter years in Service: \";
 cin >> yr1;
 
 cout << \"Enter Salary: \";
 cin >> sal1;
 cout << \"Enter employee name: \";
 cin.ignore(1);
 getline(cin, name2);
   
 
 cout << \"Enter years in service \";
 cin >> yr2;
 cout << \"Enter Salary \";
 cin >> sal2;
 cout << fixed << setprecision(2);
 cout << \" \ \";
 cout << \" \ \";
 cout << \" \ \";
 
 cout << \"Employee data\ \";
 cout<<std::left<<setw(20)<<\"Name\"<<std::right<<setw(5)<<\"Years\"<<std::right<<setw(12)<<\"Salary\ \";
  cout<<std::left<<setw(20)<<name1<<std::right<<setw(5)<<yr1<<std::right<<setw(12)<<sal1<<\"\ \";
  cout<<std::left<<setw(20)<<name2<<std::right<<setw(5)<<yr2<<std::right<<setw(12)<<sal2<<\"\ \";
  cout<<\"\ \";
 float avy=((float)(yr1+yr2)/2);
 float saly=((float)(sal1+sal2)/2);
 cout<<std::left<<setw(20)<<\"Average\"<<std::right<<setw(5)<<avy<<std::right<<setw(12)<<saly<<\"\ \";
   
 
 return 0;
 }
====================================
Output:
akshay@akshay-Inspiron-3537:~$ g++ spac.cpp
 akshay@akshay-Inspiron-3537:~$ ./a.out
 Enter employee name: Joe Thomas
 Enter years in Service: 7
 Enter Salary: 35000
 Enter employee name: Ed k.Johnson
 Enter years in service 12
 Enter Salary 9876.54
   
   
   
 Employee data
 Name Years Salary
 Joe Thomas 7 35000.00
 Ed k.Johnson 12 9876.54
Average 9.50 22438.27



