Author Topic: C++ Program for Mileage Cost Calculation  (Read 959 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
C++ Program for Mileage Cost Calculation
« on: November 02, 2011, 12:12:13 pm »
Write a program in c++ that takes input from the user of from 0 to 200.
If Mileage is less than 100 then he can charge 15.00 and if Mileage is greater than 100 then charge 10.00.
Display the total charge?


Code:
//Source Code Listing

void main()
{
   double miles = 0;
   std::cout << "Enter Mileage:";
   std::cin >> miles;

   if(miles < 0 || miles > 200)
      std::cout << "Invalid Input";
   else if(miles <= 100)
      std::cout << "Total Amount: " << miles * 15.00; 
   else
      std::cout << "Total Amount: " << (miles - 100) * 10.00 + 1500; 

   std::cout << "\n";

}


 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1