Hey everyone!
I'm trying to figure out the last step in completing this application. It compiles fine, I just can't seem to get the right answers! It's something to do with differentiating the two switch statements when calculating the results...between "car_type" and "ins_option".
I'm a beginner so I'm not too familiar with methods.
//Calculate totals and display results.
txtRentalTotal.Text = bill(car_type, num_rental_days, num_periods).ToString("C");
txtInsuranceTotal.Text = bill(ins_option, num_ins_days, num_periods).ToString("C");
txtFinalTotal.Text = (bill(car_type, num_rental_days, num_periods) + bill(ins_option, num_ins_days, num_periods)).ToString("C");
private double bill (char type, int days, int periods)
{
// Daily Rental Prices.
const double compact_price = 34.95;
const double full_price = 49.95;
const double sport_price = 75.95;
// Daily Insurance Prices.
const double collision_ins = 18.49;
const double full_ins = 34.99;
switch (car_type)
{
case 'C':
return compact_price * num_rental_days * num_periods;
case 'F':
return full_price * num_rental_days * num_periods;
case 'S':
return sport_price * num_rental_days * num_periods;
}
switch (ins_option)
{
case 'C':
return collision_ins * num_ins_days * num_periods;
case 'F':
return full_ins * num_ins_days * num_periods;
case 'N':
return 0;
default:
messageBoxOK("Fatal error: The program should never get here!");
return 0;
}
}
Any help would be appreciated!