Professional Documents
Culture Documents
3
Name: Paz, Jose Gabriel L.
Student No.: 2018151107
Course: ECE-1 Subject & Section: CPE103-1L -A12
Date: 12/17/18
1. Complete the program below using functions. All you have to do is fill in the functions with
the proper codes and methods to make the program compute for the Take Home Amount.
Make use of the predefined values. It must also display the breakdown of the computation as
follows,
Note: For your final output, number of hours worked is 12 as shown in the illustration above.
(10 pts)
#include<iostream>
double Hours_Worked()
{
void Display_Earnings(double)
{
const double Rate = 5.00;
const double Deduction = 10.00;
//To compute for taxes due, it will be (Total Earnings x 32%).
int main()
{
//Code goes here…
//main() will call Hours_Worked() to get the number of hours worked…
//main() will pass the number of hours worked to Display_Earnings()…
}
cout << "\nTotal Earnings: $" << Hrs * Rate << endl;
cout << "Taxes Due: $" << Tax << endl;
cout << "Deductions: $" << Deduction << endl;
cout << "Take Home Amount: $" << Amount_Paid << endl << endl;
}
int main()
{
int Hrs;
Hrs = Hours_Worked();
Display_Earnings(Hrs);
return 0;
}
2. Complete the following program using functions and structure. Fill in the missing code and the
program should be able to ask for the employee ID and employee name as follows,
Note: For your final output, use your student number for Employee ID and your full name as
Employee’s Name. Make sure your full name is displayed on the output. (10 pts)
#include<iostream>
#include<string>
struct Employee
{
//Code goes here…
};
int main()
{
//Code goes here…
//main() will call Get_Employee_Data() and store the returned structure.
//main() will call Display_Employee_Data and pass the structure to display
employee information…
}
Employee Get_Employee_Data()
{
//Code goes here…
//This function will store the employee details and return the structure to
main()…
}
void Display_Employee_Data(Employee)
{
//Code goes here…
//Structure will be passed from main()…
//This function will display the employee details…
}
#include<iostream>
#include<string>
using namespace std;
struct Employee
{
int ID;
string Name;
};
int main()
{
Employee The_Employee;
Employee Get_Employee_Data();
void Display_Employee_Data(Employee);
The_Employee = Get_Employee_Data();
Display_Employee_Data(The_Employee);
return 0;
}
Employee Get_Employee_Data()
{
Employee The_Employee;
return The_Employee;
}
void Display_Employee_Data(Employee The_Employee)
{
cout << "\n\nEmployee ID: " << The_Employee.ID << endl;
cout << "Employee's Name: " << The_Employee.Name << endl << endl;
}
3. Complete the program below using functions, pointers, addresses. Fill in the missing code and
the program should ask for student details and display it as follows,
Note: For your final output, use your student number and make sure your full name is
displayed. (10 pts)
#include<iostream>
#include<string>
int main()
{
//Code goes here…
//main() passes references of Student ID and Student Name to Get_Student_Details
to be initialized…
//main() passes references of Student ID and Student Name to
Display_Student_Details to display student information…
}
#include<iostream>
#include<string>
int main()
int Student_ID;
string Student_Name;
Get_Student_Details(&Student_ID, &Student_Name);
Display_Student_Details(&Student_ID, &Student_Name);
return 0;
}
cin.ignore();
getline(cin, *Student_Name);
cout << "Student Name: " << *Student_Name << endl << endl;