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
What are the ASE special certifications?
kykrilka [37]

Answer:

It is The National Institute for Automotive Service Excellence.

Explanation:

8 0
3 years ago
Read 2 more answers
If we compare the push function of the stack with the insertFirst function for general lists, we see that the algorithms to impl
Jet001 [13]

Answer:

True

Explanation:

<u>Algorithm for push function</u>

The method of placing data on a stack is called a push operation.

It involves these steps −

  • Check that the stack is complete.  
  • If the stack is complete, it will cause an error .  
  • Increases top to point next empty room if the stack is not complete.  
  • Adds the data component to the place of the stack where top is pointing.
  • Success returns.

<u>Algorithm for Insertfirst function</u>

  • Create a new Link with provided data.
  • Point New Link to old First Link.
  • Point First Link to this New Link.

As we can see that in both algorithms ,we are inserting data to a new nodes and incrementing/pointing to a new node for inserting data.Both algorithms uses the same approach.

8 0
3 years ago
(25 POINTS)Which statement best reflects the importance of following safety guidelines?
jeyben [28]

Answer:

I think, Every year, thousands of people die as a result of workplace injuries.

6 0
3 years ago
Read 2 more answers
3. Coaxial/telephone cable sends<br> during the data transmission<br> signal
Vlad1618 [11]

Answer:

high frequency signal.

3 0
2 years ago
A(n) _____ might be written by a programmer or it might be created through a DBMS utility program.
valkas [14]

Answer:

The correct answer to the following question will be "Application program".

Explanation:

  • Applications include database programs, word processors, browsers, development tools, picture editors, and platforms for communication.
  • It use the OS (Operating System) of the computer and many other assisting programs, frequently system software, to work.
  • An application program is a detailed, body-contained program that directly works a given function for just the user.

There are some examples of application programs such as:

  • Includes various bundled software.
  • Addresses an organization's data management and application requirements, covering all divisions.
  • It allows users can create and manage information.
  • Used primarily to get content access without editing.

6 0
3 years ago
Other questions:
  • Provide an example of a time in your personal or work life when you used the household measuring system and measured out an exac
    6·1 answer
  • The Microsoft-NanoServer-Guest-Package installs the drivers necessary for installing Nano Server as a host OS on a physical mach
    15·1 answer
  • What can I do if my mouse on my laptop keeps freezing on me for 5 minutes
    11·1 answer
  • HELP PLEASE
    5·1 answer
  • Do you think boot-camp-style treatment centers can help young. People kick smartphones addictions?
    14·2 answers
  • How does a hard drive work?
    5·1 answer
  • Find a 95% confidence interval for the mean failure pressure for this type of roof panel.The article "Wind-Uplift Capacity of Re
    7·1 answer
  • What is the difference between LANs and WANs and the internet
    11·2 answers
  • If you notice that a worksheet displays columns A, B, C, E, and F, what happened to column D?
    9·1 answer
  • You are making a game! The player tries to shoot an object and can hit or miss it. The player starts with 100 points, with a hit
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!