|
autoinsuranceselect.c
| |
: Implements dynamic pricing by multiplying the vehicle's market value by a specific risk multiplier.
If you'd like to expand this into a full application, would you prefer adding for policies or a more detailed premium breakdown (e.g., liability vs. collision)? autoinsuranceselect.c
: Separates the assessment logic from the interface , allowing the assess_risk function to be reused in larger systems, such as a Vehicle Insurance Management System . : Implements dynamic pricing by multiplying the vehicle's
: Uses conditional branching to categorize applicants based on high-risk demographics, such as young male drivers or inexperienced operators. : Separates the assessment logic from the interface
#include #include /** * Feature: Auto Insurance Selection & Risk Assessment * Purpose: Determines applicant eligibility and calculates * premiums based on age, sex, and vehicle value. */ // Define risk categories typedef enum RISK_NONE = 0, RISK_HIGH, RISK_MEDIUM, RISK_REDUCED, RISK_LOW RiskLevel; // Structure to store applicant data typedef struct int age; char sex; double vehicle_value; RiskLevel risk_code; double premium; Applicant; // Function prototypes RiskLevel assess_risk(int age, char sex); double calculate_premium(double value, RiskLevel risk); const char* get_risk_description(RiskLevel risk); int main() Applicant client; printf("--- Auto Insurance Selection System ---\n"); printf("Enter applicant age: "); scanf("%d", &client.age); printf("Enter sex (M/F): "); scanf(" %c", &client.sex); printf("Enter estimated vehicle value ($): "); scanf("%lf", &client.vehicle_value); // Core Logic: Risk assessment and pricing client.risk_code = assess_risk(client.age, client.sex); client.premium = calculate_premium(client.vehicle_value, client.risk_code); // Output results printf("\n--- Selection Results ---\n"); printf("Risk Status: %s\n", get_risk_description(client.risk_code)); if (client.risk_code != RISK_NONE) printf("Estimated Annual Premium: $%.2f\n", client.premium); else printf("Status: Applicant is not insurable under standard criteria.\n"); return 0; /** * Determines risk level based on demographic data. * Logic based on common insurance underwriting standards. */ RiskLevel assess_risk(int age, char sex) (age <= 30 && sex == 'M')) return RISK_HIGH; if ((age <= 30 && sex == 'F') /** * Calculates premium as a percentage of vehicle value based on risk. */ double calculate_premium(double value, RiskLevel risk) switch (risk) case RISK_HIGH: return value * 0.08; // 8% of value case RISK_MEDIUM: return value * 0.05; // 5% of value case RISK_REDUCED: return value * 0.03; // 3% of value case RISK_LOW: return value * 0.02; // 2% of value default: return 0.0; const char* get_risk_description(RiskLevel risk) const char* descriptions[] = "Not Insurable", "High Risk", "Medium Risk", "Reduced Risk", "Low Risk"; return descriptions[risk]; Use code with caution. Copied to clipboard Key Technical Aspects
: Includes input validation placeholders to handle edge cases like applicants under the legal driving age.