Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------------------
- //Programmer's Name: Ian King
- //Program: Practice
- //Description:
- // Input: No input from the user or a file
- // Process: All values are assigned in the program.
- // The quantity to0rder,totalCost, & averageCost
- // are calculated.
- // Output: The value of all assigned and calculated values are
- // displayed on the screen.
- //------------------------------------------------------------------------------
- //For input and output on the screen
- #include <iostream>
- //To use the string data type
- #include <string>
- using namespace std;
- const int QUANTITY_REQUIRED = 200;
- const int NUM_OF_ITEMS = 4;
- const string COLLEGE = "Broome Community College";
- const string MY_NAME = "Ian King";
- int main(void)
- {
- int quantityOnHand;
- int quantityToOrder;
- double cost1;
- double cost2;
- double cost3;
- double cost4;
- double totalCost;
- double averageCost;
- char firstInitial;
- char lastInitial;
- string firstName;
- string lastName;
- //Output to the screen the programmer's name & College
- cout << "-------------------------------------------------------------------" << endl;
- cout << COLLEGE << endl;
- cout << MY_NAME << endl;
- cout << "Output from the Practice" << endl;
- cout << "-------------------------------------------------------------------" << endl;
- //Set the quantity on hand
- quantityOnHand = 66;
- //Calculate the quantity to order
- quantityToOrder = QUANTITY_REQUIRED - quantityOnHand;
- //Output the quantities to the screen
- cout << "The current quantity on hand is " << quantityOnHand << endl;
- cout << "The quantity to order is " << quantityToOrder << endl;
- cout << "-------------------------------------------------------------------" << endl;
- //Set the cost of 4 purchases
- cost1 = 12.50;
- cost2 = 200.45;
- cost3 = 1200.39;
- cost4 = 39.99;
- //Calculate the total cost
- totalCost = cost1 + cost2 + cost3 + cost4;
- //Calculate the average cost
- averageCost = totalCost/NUM_OF_ITEMS;
- //Output the costs of the 4 items on the screen
- cout << "Cost of Item 1 is " << cost1 << endl;
- cout << "Cost of Item 2 is " << cost2 << endl;
- cout << "Cost of Item 3 is " << cost3 << endl;
- cout << "Cost of Item 4 is " << cost4 << endl;
- cout << endl;
- //Output the total and average of the 4 items purchased
- cout << "-------------------------------------------------------------------" << endl;
- cout << "Total Cost is " << totalCost << endl;
- cout << "Average Cost is " << averageCost << endl;
- cout << "-------------------------------------------------------------------" << endl;
- //Set the first and last initial
- firstInitial = 'C';
- lastInitial = 'S';
- //Output the two initials
- cout << "the two initials are: " << firstInitial << '.' << lastInitial << '.' << endl;
- cout << "-------------------------------------------------------------------" << endl;
- //Set the name
- firstName = "Joe";
- lastName = "Smith";
- //Output the name
- cout << "The name is " << firstName << ' ' << lastName << endl;
- cout << "-------------------------------------------------------------------" << endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment