Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- const int N = 15;
- //es1
- struct Car {
- int id;
- char model[N];
- float rentalRate;
- };
- int main() {
- Car cars[3];
- int days;
- for(int i=0; i<3; i++) {
- cout << "Enter details for car " << i+1 << ":\n";
- cout << "ID: ";
- cin >> cars[i].id;
- cout << "Model: ";
- cin >> cars[i].model;
- cout << "Rental Rate per day: ";
- cin >> cars[i].rentalRate;
- }
- cout << "Enter number of days for rental: ";
- cin >> days;
- for(int i=0; i<3; i++) {
- cout << "Total rental cost for car " << cars[i].id << " (" << cars[i].model << "): " << cars[i].rentalRate * days << "\n";
- }
- return 0;
- }
- //es2
- struct Employee {
- int id;
- char name[N];
- float salary;
- };
- int main() {
- Employee employees[3], highestSalaryEmployee;
- for(int i=0; i<3; i++) {
- cout << "Enter details for employee " << i+1 << ":\n";
- cout << "ID: ";
- cin >> employees[i].id;
- cout << "Name: ";
- cin >> employees[i].name;
- cout << "Salary: ";
- cin >> employees[i].salary;
- if(i==0 || employees[i].salary > highestSalaryEmployee.salary) {
- highestSalaryEmployee = employees[i];
- }
- }
- cout << "Employee with highest salary is " << highestSalaryEmployee.name << " (ID: " << highestSalaryEmployee.id << ") with a salary of " << highestSalaryEmployee.salary << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement