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
A(n) ________ device facilitates file sharing and data backup.
wariber [46]
A NAS device facilitates file sharing and data backup.

NAS stands for "Network Attached Storage". It a device design specially to store and manage files and within a network. It provides centralized data access and storage.
NAS is somehow considered as a specialized external hard drive.
5 0
3 years ago
Read 2 more answers
I Need Help With This I'm Just At Home Working And I Am Kinda Stuck On This Question Please Help
kvasek [131]

Answer:

move forward 300 pixels and turn right by 15 pixels

repeat then turn left instead of right

do this either 5 or 10 times idk which one

Explanation:

6 0
3 years ago
For Official Use Only (FOUO) and Controlled Unclassified Information (CUI) may include all of the following except: (circle one)
quester [9]

Answer

A. Secret Information

Explanation

For Official Use only is a security information term for designation applied by most governments. In the United States, it is used by the department of defense to handle orders for controlled Unclassified Information (CUI), and is strictly unclassified. The main purpose of this program is to eliminate inefficient and misleading patch work across agencies in the department of defense.


7 0
3 years ago
Read 2 more answers
Why do most teens prefer smartphones over laptops?
Pie

Answer:

bc social media purposes

8 0
2 years ago
using the class c ip address 195.1.1.0 (class c means that only the last octet can be used for subnet and host addresses, or sta
Lelechka [254]

Answer:

Explanation:

Given a class C IP address

195.1.1.0

Existing mask is 255.255.255.0

We want to have 12 hosts on 10 subnets.

A class C address has 8 bits of the host which will give, n=8

2ⁿ - 2 = 254 hosts

Current mask= 255.255.255.0

Bits needs for 10 subnets

2ⁿ = 10, n = 4bits

n = 4 = 2⁴ = 16 possible subnets

Now, bit needed for 12host, n =4bits

2⁴-2 = 14 possible host,

Total of 8 bits needed so therefore we can use as 4bits for the subnet.

So we could have

4 bit subnet and 4 bits hosts

11110000 = 240decimals

Final possible masks is

255.255.255.240

5 0
3 years ago
Other questions:
  • _____ allow(s) a user to double click with the mouse in a document to move the insertion point to a new location.
    11·1 answer
  • ____ is a practice where a user in enticed by possible rewards and then asked to provide personal information.
    14·1 answer
  • You should use html elements instead of server controls when
    11·1 answer
  • There are three levels of FDA approval for medical devices, with Level 1 being advanced technological products such as pacemaker
    13·1 answer
  • Which of the following is the correct order of the SDLC?
    14·1 answer
  • Ned and Mary Ann are saving their files to a CD. When prompted, Ned will click on Burn file to disk, indicate the recording spee
    15·1 answer
  • Two categories of payroll deductions are required deductions and ___ deductions.
    9·2 answers
  • In what century was plastic invented ?​
    9·1 answer
  • What is the next line?
    14·1 answer
  • How has the internet improved business communication worldwide
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!