# Computer Science Homework Help

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

#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 << ” “; Computer Science Homework Help.

}

}

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<<“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 = “<

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

}

else

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

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

cin>>input;

if(input == ‘n’)