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]
3 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]3 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
Code Problem 3 in Python 2.
11111nata11111 [884]

I've included my code in a picture below. I hope this helps.

7 0
3 years ago
What are the 6 external parts of a computer system
denis23 [38]
1. Monitor
2.C.P.U
3.Mouse
4. Keyboard
5. Printer
6. Speaker
4 0
3 years ago
What is the energy conversion of solar water heaters?
Gelneren [198K]
A liquid-to-liquid heat exchanger uses a heat-transfer fluid that circulates through the solar collector, absorbs heat, and then flows through a heat exchanger to transfer its heat to water in a storage tank. Heat-transfer fluids, such as antifreeze, protect the solar collector from freezing in cold weather.
7 0
3 years ago
What is the term for a set of actions carried out on inputs?
Ymorist [56]

Answer:

<u><em>Input Bindings</em></u> is the term that is used for actions carried out on inputs in automation process.

Explanation:

In Automation process different operation or tasks had been performed such as output, input, internal actions. These are known as action bindings.

At input terminal the actions that are being carried out are called Input bindings. A command is comes from control pin and data is comes from input pin. This input and control signal combines together and perform the action that is required by machine or device.

<em>This is the reason these actions performed at input device is called Input Binding.</em>

8 0
3 years ago
Point out the correct statement.
NeTakaya

Answer:

Option D is correct.

Explanation:

Cassandra labeling information with such a gravestone indicates should restart transmitting an erase request to such a duplicate that had been down earlier of deletion.

Cassandra may not instantly delete information labeled for removal from disc the removal of identified information takes place throughout compaction a deleted section may reappear when a maintenance is never regularly carried out.

4 0
3 years ago
Other questions:
  • In addition to not parking where signs prohibit it, you should never park __________________.
    12·1 answer
  • Create a text file that contains your expenses for last month in the following categories: • Rent • Gas • Food • Clothing • Car
    13·1 answer
  • In the game of economics, which player has the role of providing goods and services
    10·1 answer
  • Which tabs contains options for adding shapes to a chart ? Check all that apply.
    13·1 answer
  • Engineers and scientists redesign a prototype if it does not work correctly true or false and why
    10·2 answers
  • Why are ethics important in PR?
    8·1 answer
  • How scientist and technology beliefs society
    14·1 answer
  • What is the output?
    11·1 answer
  • Robert is risk manager at TPT Bank has been asked to implement an updated badge reader system for addressing access control risk
    8·1 answer
  • To make changes to how UAC operates, you must be logged in as administrator true or false
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!