fork download
  1. int main()
  2. {
  3. int km, kmc;
  4. float price;
  5.  
  6. printf(" Enter distance(Kilometer) : ");
  7. scanf("%d", &km);
  8.  
  9. if(km > 80){
  10. kmc = (km - 80);
  11. price += kmc * 10.50;
  12. km -= kmc;
  13. }
  14. if(km > 60){
  15. kmc = (km - 60);
  16. price += kmc * 9;
  17. km -= kmc;
  18. }
  19. if(km > 40){
  20. kmc = (km - 40);
  21. price += kmc * 8;
  22. km -= kmc;
  23. }
  24. if(km > 20){
  25. kmc = (km - 20);
  26. price += kmc * 7.50;
  27. km -= kmc;
  28. }
  29. if(km > 10){
  30. kmc = (km - 10);
  31. price += kmc * 6.50;
  32. km -= kmc;
  33. }
  34. if(km > 1){
  35. kmc = (km - 1);
  36. price += kmc * 5.50;
  37. km -= kmc;
  38. }
  39. if(km == 1){
  40. price += 35;
  41. }
  42.  
  43. if((int)round(price) % 2 == 0){
  44. price += 1;
  45. }
  46.  
  47. printf("\r\n Taxi fare is %.0f baht\r\n", price);
  48.  
  49. return 0;
  50. }
Success #stdin #stdout 0.01s 5436KB
stdin
Standard input is empty
stdout
 Enter distance(Kilometer) : 
 Taxi fare is 343853 baht