Guest User

Untitled

a guest
Oct 18th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. /*Write a C program that computes the toll for a vehicle traveling on a toll highway. Your main method
  2. will ask the user for the following input data:
  3. - the classification of the vehicle (passenger car, small truck, or large truck) and
  4. - if the vehicle is not a passenger car, the number of miles driven on the toll road
  5. - if the vehicle is a large truck, the weight of the truck in tons.
  6. You may assume that all input numerical data is of the proper form and will not contain negative values or
  7. zero. Depending on the input data value(s), the program will calculate and display the amount of the toll
  8. charge for using the highway.
  9. Toll fees are calculated according to the following rules:
  10. Classification Rate
  11. Passenger Vehicle $2.25
  12. Small Truck $3.00 + $0.40 for each mile
  13. Large Truck $36.00 + $1.10 for each mile beyond 100 miles + $20.00 per ton for the first 5
  14. tons + $25.00 per ton for any additional tons above 5 tons.
  15. The vehicle classification will be entered as two letters ('PC' for Passenger car, 'ST' for Small truck, 'LT' for
  16. Large Truck). All numerical measurements (miles and tons) are entered as integers.*/
  17. #include<iostream>
  18. using namespace std;
  19. int main()
  20. {
  21. char x[20];
  22. int dist,gr;
  23. float s=0;
  24. cout<<"Tip masina:";
  25. cin>>x;
  26. if(x[0]=='P'&&x[1]=='V')
  27. cout<<"$2.25";
  28. if(x[0]=='S'&&x[1]=='T')
  29. {
  30. cout<<"Distanta parcursa:";
  31. cin>>dist;
  32. s=3+0.40*dist;
  33. cout<<'$'<<s;
  34. }
  35. if(x[0]=='L'&&x[1]=='T')
  36. {
  37. s=0;
  38. cout<<"Distanta parcursa:";
  39. cin>>dist;
  40. cout<<"Greutate:";
  41. cin>>gr;
  42. if(dist>100)
  43. s=s+36+1.10*(dist-100);
  44. else
  45. s=36;
  46. if(gr<=5)
  47. s=s+20.00*gr;
  48. else
  49. s=s+25.00*gr-25;
  50. cout<<s;
  51. }
  52. }
Add Comment
Please, Sign In to add comment