#include using namespace std; // utility function void strToBinary(string s) { int n = s.length(); for (int i = 0; i <= n; i++) { // convert each cha

We are confident that we have the best essaywriters in the market. We have a team of experienced writers who are familiar with all types of essays, and we are always willing to help you with any questions or problems you might face. Plus, our writers are always available online so you can always get the help you need no matter where you are in the world.


Order a Similar Paper Order a Different Paper

#include

using namespace std;

// utility function

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

void strToBinary(string s)

{

int n = s.length();

for (int i = 0; i <= n; i++)

{

// convert each char to

// ASCII value

int val = int(s[i]);

// Convert ASCII value to binary

string bin = “”;

while (val > 0)

{

(val % 2)? bin.push_back(‘1’) :

bin.push_back(‘0’);

val /= 2;

}

reverse(bin.begin(), bin.end());

cout << bin << ” “;

}

}

int main ()

{

vector beverages(3);

beverages[0] = “Water”; //Entering beverage Water

beverages[1] = “Pepsi”; //Entering beverage Pepsi

beverages[2] = “Coke”; //Entering beverage Coke

vectorprice(3);

price[0] = 1.50; //Price of beverage

price[1] = 1.75; //Price of beverage

price[2] = 1.00; //Price of beverage

vectordrink_counts(3);

drink_counts[0] = 10;

drink_counts[1] = 10;

drink_counts[2] = 10;

char

input;

do

{

cout<<“n Please Select Beverages using keypad!nn”;

cout<<“Available choices are as followes: n1. Water : A1 n2. Pepsi: B2 n3. Coke: C3 n”;

string choice;

cin>>choice;

int beverageId = -1;

if(choice == “A1”) //Beverage selection as A1

beverageId = 0;

else if(choice == “B2”) //Beverage selection as B2

beverageId = 1;

else if(choice == “C3”) //Beverage selection as C3

beverageId = 2;

else

cout<< “Wrong Selectionn”; // Throw error message of selection is wrong

if (beverageId != -1)

{

cout<<“$”<

string s = “<<<>>>>”;

string s = “<<<>>>>”;

strToBinary(s);

}

else

continue;

if (drink_counts[beverageId] > 0)

{

drink_counts[beverageId] = drink_counts[beverageId] – 1;

int money = 0;

char ch = ‘y’;

// Use While loop

while (ch != ‘n’)

{

cout<< “Enter the amount in $1 or $5 or $10 billsn”;

int amountEntered;

cin>>amountEntered;

if (amountEntered != 1 && amountEntered != 5 && amountEntered != 10) //This will show amount entered

{

cout<< “Invalid amount. Please try againn”;

ch = ‘y’;

continue;

}

money += amountEntered;

if(money >= price[beverageId])

break;

cout<<“Remaining Amount = “<

cout<<“Please Enter more money: (y/n)n”;

cin>>ch;

}

if (money < price[beverageId])

cout<<“Not enough money to buy drink, Transaction Cancelledn”;

if(money == price[beverageId])

cout<< “Thank you! Enjoy your Beverage!n”;

else

cout<< “Please take your Change = ” << money – price[beverageId]<<“n”;

}

else

cout<< “Selected Beverage is out of stockn”;

cout<<“Do you need more beverages (y/n) “;

cin>>input;

if(input == ‘n’)

cout<<“Thanks for buying drinks”<<“n”;

}

while(input == ‘y’ || input == ‘Y’);

return 0;

}

Writerbay.net

Do you have a lot of essay writing to do? Do you feel like you’re struggling to find the right way to go about it? If so, then you might want to consider getting help from a professional essay writer. Click one of the buttons below.


Order a Similar Paper Order a Different Paper