The following program is used in a bookstore to determine how many discount coupons a customer gets. Complete the table that appears after the program.
#include <iostream>
using namespace std;
int main(}
{
int numBooks, numCoupons;
cout << "How many books are being purchased?";
cin >> numBooks;
if (numBooks < 1)
numCoupons = 0;
else if (numBooks < 3}
numCoupons = 1;
else i f (numBooks < 5}
numCoupons = 2;
else
numCoupons = 3;
cout << "The number of coupons to give is"<< numCoupons << endl;
return 0;
}
If the customer purchases this many book s ... | ... This many coupons are given. |
1 | |
2 | |
3 | |
4 | |
5 | |
10 |
Trending nowThis is a popular solution!
Chapter 4 Solutions
Starting Out with C++: Early Objects (9th Edition)
Additional Engineering Textbook Solutions
Digital Fundamentals (11th Edition)
Starting Out with Java: From Control Structures through Objects (6th Edition)
Modern Database Management (12th Edition)
C How to Program (8th Edition)
Database Concepts (8th Edition)
Starting Out with Python (4th Edition)
- #include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…arrow_forwardusing System; using System.Linq; using System.Text; namespace Games; { class Program { staticvoid Main(string[] args) { int choice,games_choice; cout<<"What are your favorite games - outdoor or indoor"<<endl; cout<<"Press 1 for 'outdoor' or Press 2 for 'indoor'"<<endl; cin>>choice; if(choice==1) { cout<<"What is your favorite outdoor game"<<endl; cout<<"Press 1 for Tennis"<<endl; cout<<"Press 2 for Football"<<endl; cout<<"Press 3 for Cricket"<<endl; cin>>games_choice; if(games_choice==1) cout<<"I also like Tennis"<<endl; elseif(games_choice==2) cout<<"I also like Football"<<endl; elseif(games_choice==3) cout<<"I also like Cricket"<<endl; } elseif(choice==2) { cout<<"What is your favorite indoor game"<<endl; cout<<"Press 1 for Ludo"<<endl; cout<<"Press 2 for Chess"<<endl; cout<<"Press 3 for Cards"<<endl;…arrow_forwardC programming language questionarrow_forward
- Void Do1 (int: &, a. int &b) { a = 5; a = a + b; b = a + 2; } Int main() { Int x = 10; Do1 (x,x); Cout << x << endl; } The output of this program isarrow_forward#include void main () { int a=5,b=10,c=1; if (a && b>c) { printf("cquestionbank"); } else{ break; } }arrow_forwardLowest Score Drop Write a program that calculates the average of a group of test scores, where the lowest score in the group is dropped. It should use the following functions: void getScore() should ask the user for a test score, store it in a reference parameter variable, and validate it. This function should be called by main once for each of the five scores to be entered. void calcAverage() should calculate and display the average of the four highest scores. This function should be called just once by main and should be passed the five scores. int findLowest() should find and return the lowest of the five scores passed to it. It should be called by calcAverage, which uses the function to determine which of the five scores to drop. Input Validation: Do not accept test scores lower than 0 or higher than 100.arrow_forward
- Text-based adventure game: Pretend you are creating a text-based adventure game. At different points in the game, you want the user to select to fight, run, or hide from certain enemies. Modify the application below (week3.py) so that the selection variable is sent as an argument into the choice() function. The user should enter 1 to fight, 2 to run, or 3 to hide in the main(). The choice() function should print one of the three options. You will need to add an if statement in the choice() function to make the correct selection.arrow_forwarddef main(): monthlySales = getSales() printbonus=print_bonus(storeAmount,empAmount) #This function gets the monthly salesdef getSales(): monthlySales = float(input('Enter the monthly sales $')) monthlySales = getSales() #call to get sales salesIncrease = getIncrease(monthlySales) return monthlySales #This function gets the percent of increase in salesdef getIncrease(monthlySales): storeAmount = storeBonus(monthlySales) salesIncrease = float(input('Enter percent of sales increase: ')) salesIncrease = float(salesIncrease) salesIncrease = salesIncrease / 100 return salesIncrease #This function determines the storeAmount bonusdef storeBonus(monthlySales): if monthlySales >= 110000: storeAmount = 6000 elif monthlySales >= 100000: storeAmount = 5000 elif monthlySales >= 90000: storeAmount = 4000 elif monthlySales >=80000: storeAmount = 3000 else: storeAmount = 0 return storeAmount #This function…arrow_forwardC++ beginnerarrow_forward
- Number guessing Game Write a C program that implements the “guess my number” game. The computer chooses a random number using the following random generator function srand(time(NULL)); int r = rand() % 100 + 1; that creates a random number between 1 and 100 and puts it in the variable r. (Note that you have to include <time.h>) Then it asks the user to make a guess. Each time the user makes a guess, the program tells the user if the entered number is larger or smaller than its number. The user then keeps guessing till he/she finds the number. If the user doesn’t find the number after 10 guesses, a proper game over message will be shown and the actual guess is revealed. If the user makes a correct guess in its allowed 10 guesses, then a proper message will be shown and the number of guesses the user made to get the correct answer is also printed. After each correct guess or game over, the user decides to play again or quit and based on the user choice, the computer will make…arrow_forward#include int main() { float Bread = 1.09, Water = 2.18, Banana = 1.00, Meat = 7.99; //Unit for bread is loaf, for water is bottle, for banana and meat are Ibs. int Bread_num=2, Water_num=3, Banana_num=2, Meat_num = 1; float Cost = Bread"Bread_num+Water*Water_num+Banana*Banana_num+Meat"Meat_num; float Grocery_tax = 0.07; Other part of this line is missing. Other part of this line is missing as well. [printf( [printf( getchar(); return O; } -----=-SCRIPT ENDS HERE ==== so we can have You have 2 loaves of bread, 3 bottles of water, 2 lbs of Banana, and 1 lbs of Meat. It is 18.71 before tax but you need to pay extra 1.31 for tax. as the output when we run it! Just type in two line, please! (You do not have to type in the whole script!)arrow_forwardC++: Describe how the following call by reference works. Make a comment for each line. void pxc(int& c, int& d) { int k = c; c = d; d = k; } int main() { int a = 15, b = 100; pxc(a, b); }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education