fork download
  1. //OrinTill Qimid CS1A Chapter 4, P. 221, 10
  2. //
  3. /**************************************************************
  4.  * calculate call charges
  5.  *
  6.  * ____________________________________________________________
  7.  * This program will claculate how much it would cost for long distance call.
  8.  * ____________________________________________________________
  9.  * INPUT
  10.  * when : the time of the call.
  11.  * time : how long the call was.
  12.  * OUTPUT
  13.  * cost : the total cost of the phone call.
  14.  **************************************************************/
  15. #include <iostream>
  16. #include <iomanip>
  17. #include <cmath>
  18. using namespace std;
  19.  
  20. int main()
  21. {
  22. float when,
  23. time,
  24. cost;
  25. cout<<"At what time was your phone call?(please enter in HH.MM ex 7:00 is 7.00)"<<endl;
  26. cin>> when;
  27. if (when<0)
  28. {
  29. cout<<"sorry that's not a valid time"<< endl;
  30. }
  31. cout<<"How long as your phone call?"<< endl;
  32. cin>>time;
  33. if (when<=6.59)
  34. {
  35. cost = time * 0.12;
  36. cout<<"your cost would be $"<<cost<<endl;
  37. }
  38. else if (when<=19.00)
  39. {
  40. cost=time * 0.55;
  41. cout<<"your cost would be $"<<cost<<endl;
  42. }
  43. else if (when<=23.59)
  44. {
  45. cost=time * 0.35;
  46. cout<<"your cost would be $"<<cost<<endl;
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54. return 0;
  55. }
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
Standard output is empty