1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Gennadij [26K]
2 years ago
11

Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with e

very purchase of 8 or more books. It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books.
Write a statement that assigns freeBooks the appropriate value based on the values of the bool variable isPremiumCustomer and the int variable nbooksPurchased .


I tried
if (isPremiumCustomer==true)
{
if (nbooksPurchased >= 5)
{
freeBooks==1;
{
if (nbooksPurchased >= 8)
{
freeBooks==2;
}
}
}
}
else if (isPremiumCustomer==false)
{
if (nbooksPurchased >= 7)
{
freeBooks==1;
{
if (nbooksPurchased >= 12)
{
freeBooks==2;
}
}
}
}

but the system said:
Remarks:
? At Execution

Problems Detected:
? The value of freeBooks is incorrect.
? You did not assign a value to freeBooks

and this one ......


Write a loop that reads strings from standard input where the string is either "duck" or "goose". The loop terminates when "goose" is read in. After the loop, your code should print out the number of "duck" strings that were read.
Computers and Technology
1 answer:
andrey2020 [161]2 years ago
6 0

Answer:

This question has two parts, first part is about programming about a Player class and second for reading string from user and decide how many time duck string entered by user and terminate if user press goose string.

The explanation of both program (executable code) is given below in explanation section.

Explanation:

//Program 1

#include <iostream>

using namespace std;

int main()

{

 bool isPremiumCustomer;

 int nbooksPurchased;

 int totalBookPurchasedWithOffer;

// bool cutomerType;

 int freeBooks;

 cout<<"Press 1 for Premium Customer and 0 for regular Customer";

 cin>>isPremiumCustomer;

 cout<<"How many books you purchased ";

 cin>>nbooksPurchased;

 

 

switch(isPremiumCustomer)// what type of customer is  

{

case 1://if customer is premium

 if (nbooksPurchased >= 5&&nbooksPurchased<8)// purchase book greater between 5 and 8

  {

   freeBooks=1;//offer free book

   totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;//total number of book including free book

   

   cout<<"You purchased total book with offer ";//show total books

   cout<<totalBookPurchasedWithOffer;

  }

   

  else if (nbooksPurchased >= 8)//if premium customer purchase more than 8 book

    {

    freeBooks=2;//offer two free book

    totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;//total number of book including free book

    cout<<"You purchased total book with offer ";

    cout<<totalBookPurchasedWithOffer;//show total books

    }

  else{

   cout<<"You purchased total book with no offer ";

    cout<<nbooksPurchased;

   }

  break;

case 0:// if customer is regular customer

 if (nbooksPurchased >= 7&&nbooksPurchased<12)//and purchase book between 7 and 12

  {

   freeBooks=1;// offer 1 free book

   totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;

   cout<<"You purchased total book with offer ";

   cout<<totalBookPurchasedWithOffer;

  }

   

  else if (nbooksPurchased >= 12)//if purchase 12 or more than 12 book

    {

    freeBooks=2;//offer two free book

    totalBookPurchasedWithOffer=nbooksPurchased+freeBooks;

    cout<<"You purchased total book with offer ";

    cout<<totalBookPurchasedWithOffer;

    }

 else{

  cout<<"You purchased total book with no offer ";

  cout<<nbooksPurchased;

  }

  break;

 

}

 

 

 

return 0;// terminate the program

 

}

/* program 1 has ended

and program 2 is started from here

#######################################################

*/

#include <iostream>

using namespace std;

int main()

{

string readstring;// take input string from user to enter either "goose" or "duck"

int count=0;//count the number of "duck"

while(readstring!="goose")//run loop, until user do not enter string  

{

 cout<<"Enter the string either goose or duck ";// prompt user to enter the string

 cin>> readstring;// read string from user

 if (readstring=="duck")//if string equal to "duck"

 {

  count=count+1;//count number of duck string enter by user

   

 }

}//exit/terminate the loop, if user enter the goose string

cout<< " Number of duck that were read " ;// show how many duck string entered by user

cout<<count;

return 0;// terminate the program

 

}

You might be interested in
Assume that an int variable counter has already been declared. Assume further a variable counterPointer of type "pointer to int"
Triss [41]

Answer:

Following are the statement:

counterPointer = &counter;

Explanation:

The following statement is correct because in the question it is given that there is an integer data type variable i.e., "counter" and there is another integer data type pointer variable i.e., "counterPointer" and finally we write a statement in which the pointer variable points to the integer variable.

5 0
3 years ago
Which statement describes what happens when a user configures No Automatic Filtering in Junk Mail Options?
NeTakaya

Answer: Most obvious spam messages will still reach the client computer

Explanation:

It should be noted that by default, usually the junk email filter is already set to No Automatic Filtering.

When a user configures No Automatic Filtering in Junk Mail Options, it should be noted that most obvious spam messages will still reach the client computer.

Therefore, the correct option is D.

5 0
3 years ago
The dome of Hagia Sophia rests on these curving, triangular features of Byzantine architecture called __________.
kipiarov [429]

Answer:

pendentives

Explanation:

4 0
3 years ago
What difference between plagiarism and fair use?
Alekssandra [29.7K]
Plagiarism is quite a bad thing because if you plagiarize, you are copying and pasting other people's work and using the work as yours (even though you change the sentence structure/ some words, it is still plagiarizing.) Fair use means un-biasness.
7 0
3 years ago
In general, WAN-specific standards identify specific security requirements for WAN devices. For example, the ___________________
allsm [11]

Answer:

WAN router security standard, Web services standard

Explanation:

Complete statement with blanks filled:

In general, WAN-specific standards identify specific security requirements for WAN devices. For example, the WAN router security standard explains the family of controls needed to secure the connection from the internal network to the WAN router, whereas the Web services standard identifies which controls are vital for use of Web services provided by suppliers and external partnerships.

7 0
2 years ago
Other questions:
  • When inside a closed work environment, its okay to openly talk with co-workers about PII
    6·1 answer
  • Data administration is a special organizational function that manages the policies and procedures through which data can be mana
    9·1 answer
  • Create a class called Clock to represent a Clock. It should have three private instance variables: An int for the hours, an int
    15·1 answer
  • What is the process of copying items from ram to a storage device?
    8·1 answer
  • All resources are limited. Which of the following is NOT a resource?
    11·1 answer
  • You work in the Accounting department and have been using a network drive to post Excel workbook files to your file server as yo
    15·1 answer
  • What is the approximate boiling point
    7·1 answer
  • PLEASE I NEED HELP PLEASE PLEASE<br> Which function prompts the user to enter information?
    9·1 answer
  • Which of these might be an example of an advertiser's target group?
    12·2 answers
  • Giving out 15 points to whoever answers early!
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!