C++ Questions about code. I have bolded the lines I have a question on, and my q
ID: 3700110 • Letter: C
Question
C++ Questions about code. I have bolded the lines I have a question on, and my questions are italisized and bolded. Please explain as best as you can, maybe use other examples. #include<iostream> #include<string.h> //why doesn't it work as just '#include<string.h>? #include<iomanip> using namespace std; class PayRaise { public: PayRaise(char * = " " , float = 0.0, float = 0.0); ~PayRaise(); void printData(); //what exactly is printData? Where does it come from? What's it doing? void calcBonus(float); private: char name[20]; float oldpay, raiseper, raiseamount, newpay; }; PayRaise::PayRaise(char *n, float o, float rp) // what's the two colons? { strcpy(name, n); oldpay = o; raiseper = rp; raiseamount = oldpay*raiseper/100; //I don't really get this bolded part. Please explain what you can newpay = oldpay + raiseamount; } PayRaise::~PayRaise() { cout<<"the name of "<<name<<" is destroyed"<<endl; } void PayRaise::printData() { cout<<setprecision(2)<<showpoint<<fixed; cout<<"The person's name is "<<name<<endl; cout<<"The old pay amount is $"<<oldpay<<endl; cout<<"The raise percentage is "<<raiseper<<endl; cout<<"The raise amount is $"<<raiseamount<<endl; cout<<"The new pay is $"<<newpay<<endl; } void PayRaise::calcBonus(float bonusamount) { oldpay += bonusamount; raiseamount = oldpay*raiseper/100; newpay = oldpay+ raiseamount; } int main() { PayRaise p ("Corby Bryan", 50000, 10); p.printData(); cout<<endl<<"How much is the bonus? "; float bonus; cin>>bonus; p.calcBonus(bonus); p.printData(); cout<<endl; return 0; }
Explanation / Answer
below i have explained the complete code..comments are highlighted in bold.
==============================================================
#include<iostream>
===============================================================
Kindly Check and Verify Thanks..!!!
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.