Answer to Question #243211 in C++ for Dino

Question #243211

Problem 3: A bookseller has a book club that awards points to its customers based on the number of books purchased each month. The points are 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 pseudocode program that asks the user to enter the number of books that he or she has purchased this month and then displays the number of points awarded


1
Expert's answer
2021-09-28T00:49:43-0400
//ask for user input for n
//if n >= 4 points = 60
//if n == 3 points = 30
//if n == 2 points = 15
//if n == 1 points = 5
//if n == 0 points = 0
#include <iostream>
using namespace std;
int main(){
    cout<<"Enter the number of books you purchased this month: ";
    int n, points; cin>>n;
    
    if(n > 3){
        points = 60;
    }
    else if(n > 2){
        points = 30;
    }
    else if(n > 1){
        points = 15;
    }
    else if(n > 0){
        points = 5;
    }
    else{
        points = 0;
    }
    cout<<"Points: "<<points<<endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS