Activity: If-Else and Discounts (iPad)

The Assignment

Working with your partner, write a C++ program which reads in the number of items a user wants to buy (an integer) and then computes the final cost (a real number). Items cost $5 each but customers will receive a $10 discount (i.e. subtract $10 from their total) if their total bill is at least $50. You should  compute the final cost in the variable cost.

Begin by creating a new C++ file called Discount.cpp in a C++ compiler. Next, copy and paste this starter code into the file:

#include <iostream>
using namespace std;

int main() 
{
   // declare a variable to store the total cost...
   double cost = 0.0;
   // declare a variable to contain the number of items (an int)...

   // Receive the number of items from the user (no prompt)....


   /* add an output statement with a descriptive message about how many items
      were entered by the user... */

   /* Calculate the total cost and store it in the variable "cost". You need to
      make a decision here: Recall items cost $5 each with a $10 discount if the
      total is at least $50... */

   // output the final cost...
   cout << "Final cost is $" << cost << endl;

   // return "success" to the operating system (OS)...
   return 0;
}

Modify the code to complete the assignment. When you have completed the assignment, demonstrate it for the instructor.