Hi all, I'm new to Matlab and programming. I'm trying to solve a question but when I run the script it asks me for the values and when I enter them it doesn't print anything. Can anyone please tell me what is the problem?
clcclear allcar = input('Enter the tybe of the, Sedan or SUV: ','s');days = input('Enter the number of days: ');miles = input('Enter the miles travelled: ');cartype = char(car);switch cartype case char('Sedan') if days>=1 && days<=6 if miles<=80 rent1 = (79*days)+((miles-80)*0.69); fprintf('The cost of the rent is %6.2f $. \n',rent) end elseif days>=7 && days<=29 if miles<=100 rent2 = (69*days)+((miles-100)*0.59); fprintf('The cost of the rent is %6.2f $. \n',rent) end elseif days>=30 if miles<=120 rent3 = (59*days)+((miles-120)*0.49); fprintf('The cost of the rent is %6.2f $. \n',rent) end end case char('SUV') if days>=1 && days<=6 if miles<=80 rent4 = (84*days)+((miles-80)*0.74); fprintf('The cost of the rent is %6.2f $. \n',rent) end elseif days>=7 && days<=29 if miles<=100 rent5 = (74*days)+((miles-100)*0.64); fprintf('The cose of the rent is %6.2f $. \n',rent) end elseif days>=30 if miles<=120 rent6 = (64*days)+((miles-120)*0.54); fprintf('The cost of the rent is %6.2f $. \n',rent) end endend
Best Answer