#include <iostream>
typedef struct {
std::string name;
char category;
double salary;
double tax;
void getTax () {
if (category == 'A') {
tax = 0.1;
} else if ( category == 'B' ) {
tax = 0.15;
} else if ( category == 'B' ) {
tax = 0.2;
} else {
tax = 0.3;
}
}
double calculateSalary () {
return salary - (salary * tax);
}
} Employee;
int main() {
Employee Eric = new Employee();
sts::cout << "Enter name, category and salary for employee" << std::endl;
std::cin >> Eric.name >> Eric.category >> Eric.salary;
Eric.getTax();
Eric.salary = Eric.calculateSalary();
std::cout << Eric.name << "'s salary is " << Eric.salary << std::endl;
delete Eric;
return 0;
}
#include <iostream>
int main() {
int minutes;
std::cout << "Enter total minutes talked" << std::endl;
std::cin >> minutes;
std::cout << "You owe us " << minutes << " cents" << std::endl;
return 0;
}
Comments
Dear visitor, please use panel for submitting new questions
Can you write this program in C programming and not C++? 1. define a structure employee with name, category , salary, tax as a member. read the name category and salary of employee and calculate the tax as below categories A 10% OF SALARY B 15% OF SALARY C 20% OF SALARY OTHERS 30% OF SALARY 2.firstly write a program to accept the number of telephone calls made by a customer and the print out the rate in cents.
Leave a comment