Guest User

Untitled

a guest
Oct 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.16 KB | None | 0 0
  1. //------------------------------------------------------------------------------
  2. //Programmer's Name: Ian King
  3. //Program: Practice
  4. //Description:
  5. // Input: No input from the user or a file
  6. // Process: All values are assigned in the program.
  7. // The quantity to0rder,totalCost, & averageCost
  8. // are calculated.
  9. // Output: The value of all assigned and calculated values are
  10. // displayed on the screen.
  11. //------------------------------------------------------------------------------
  12.  
  13. //For input and output on the screen
  14. #include <iostream>
  15.  
  16. //To use the string data type
  17. #include <string>
  18.  
  19. using namespace std;
  20.  
  21. const int QUANTITY_REQUIRED = 200;
  22. const int NUM_OF_ITEMS = 4;
  23.  
  24. const string COLLEGE = "Broome Community College";
  25. const string MY_NAME = "Ian King";
  26.  
  27. int main(void)
  28. {
  29. int quantityOnHand;
  30. int quantityToOrder;
  31.  
  32. double cost1;
  33. double cost2;
  34. double cost3;
  35. double cost4;
  36. double totalCost;
  37. double averageCost;
  38.  
  39. char firstInitial;
  40. char lastInitial;
  41.  
  42. string firstName;
  43. string lastName;
  44.  
  45. //Output to the screen the programmer's name & College
  46. cout << "-------------------------------------------------------------------" << endl;
  47. cout << COLLEGE << endl;
  48. cout << MY_NAME << endl;
  49. cout << "Output from the Practice" << endl;
  50. cout << "-------------------------------------------------------------------" << endl;
  51.  
  52. //Set the quantity on hand
  53. quantityOnHand = 66;
  54.  
  55. //Calculate the quantity to order
  56. quantityToOrder = QUANTITY_REQUIRED - quantityOnHand;
  57.  
  58. //Output the quantities to the screen
  59. cout << "The current quantity on hand is " << quantityOnHand << endl;
  60. cout << "The quantity to order is " << quantityToOrder << endl;
  61. cout << "-------------------------------------------------------------------" << endl;
  62.  
  63. //Set the cost of 4 purchases
  64. cost1 = 12.50;
  65. cost2 = 200.45;
  66. cost3 = 1200.39;
  67. cost4 = 39.99;
  68.  
  69. //Calculate the total cost
  70. totalCost = cost1 + cost2 + cost3 + cost4;
  71.  
  72. //Calculate the average cost
  73. averageCost = totalCost/NUM_OF_ITEMS;
  74.  
  75. //Output the costs of the 4 items on the screen
  76. cout << "Cost of Item 1 is " << cost1 << endl;
  77. cout << "Cost of Item 2 is " << cost2 << endl;
  78. cout << "Cost of Item 3 is " << cost3 << endl;
  79. cout << "Cost of Item 4 is " << cost4 << endl;
  80. cout << endl;
  81.  
  82. //Output the total and average of the 4 items purchased
  83. cout << "-------------------------------------------------------------------" << endl;
  84. cout << "Total Cost is " << totalCost << endl;
  85. cout << "Average Cost is " << averageCost << endl;
  86. cout << "-------------------------------------------------------------------" << endl;
  87.  
  88. //Set the first and last initial
  89. firstInitial = 'C';
  90. lastInitial = 'S';
  91.  
  92. //Output the two initials
  93. cout << "the two initials are: " << firstInitial << '.' << lastInitial << '.' << endl;
  94. cout << "-------------------------------------------------------------------" << endl;
  95.  
  96. //Set the name
  97. firstName = "Joe";
  98. lastName = "Smith";
  99.  
  100. //Output the name
  101. cout << "The name is " << firstName << ' ' << lastName << endl;
  102. cout << "-------------------------------------------------------------------" << endl;
  103.  
  104. return 0;
  105.  
  106. }
Add Comment
Please, Sign In to add comment