#include <stdio.h>
struct Car {
char name[20];
int id;
float price;
};
int main() {
struct Car cars[] = {
{"Toyota", 1, 50.0},
{"Honda", 2, 60.0},
{"Ford", 3, 55.0}
};
int choice, days;
printf("Available cars:\n");
for (int i = 0; i < 3; i++) {
printf("%d. %s - $%.2f per day\n", cars[i].id, cars[i].name, cars[i].price);
}
printf("Enter car ID to rent: ");
scanf("%d", &choice);
printf("Enter number of days: ");
scanf("%d", &days);
if (choice >= 1 && choice <= 3) {
float total = cars[choice - 1].price * days;
printf("Total cost for renting %s for %d days: $%.2f\n", cars[choice - 1].name, days, total);
} else {
printf("Invalid car selection.\n");
}
return 0;
}