151k views
1 vote
Serendipity Booksellers has a book club that awards points to its customers based onthe number of books purchased each month . The points arc awarded as follows:• If a customer purchases 0 books, he or she earns 0 points.• If a customer purchases 1 book, he or she earns 5 points.• If a customer purchases 2 books, he or she earns 15 points.• If a customer purchases 3 books, he Or she earns 30 points.• If a customer purchases 4 or more books, he or she earns 60 points.write a program that asks the user to enter the number of books that he or she haspurchased [his month and then displays the number of points awarded.

User Freshr
by
6.0k points

1 Answer

4 votes

Answer:

The program is written as

#include<iostream>

int main()

{

//declare variables that we are going to need

//to store user input, and number of points

into books, points;

//prompt the user to enter number of books bought

//and read from keyboard

cout << "How many books have you bought this month?\\";

cin >> books;

//use switch statement to determine number of points

//awarded according to number of books, and set that to

//variable points

switch (books){

case 0:

points = 0;

break;

case 1:

points = 5;

break;

case 2:

points = 15;

break;

case 3:

points = 30;

break;

default:

points = 60;

break;

}

//print number of points on screen

cout << "The number of points you have earned this month is " << points << ".\\";

//return 0 to mark successful completion of program and return to zero.

return 0;

User Thomas Kelley
by
6.1k points