Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1: You often need to convert Rupees into coins of 5, 2, and 1. Your tas

ID: 3731971 • Letter: Q

Question

Question 1: You often need to convert Rupees into coins of 5, 2, and 1. Your task is to develop a C++ program to compute a mix of coins of 5, 2 and 1 against the given amount of money. Remember that you may not always have enough coins. So the program should be able to covert the money into the coins available. For example, if you don't have the coins of 5-rupees, then for 7 rupees the program should compute a mix of 2-rupees and 1-rupee coins. At start the program should take input total number of 5-rupees, 2-rupees and 1-rupee coins available. The program should display the amount of money in terms of numbers of 5-rupees coins, 2-rupees coins and 1-rupee coins, if possible with the available set of coins. Otherwise print the message "Sorry!! No such combination exists. Question 2: Draw following Pattens for any positive values provided by user as input Hexagone Cross Sign to Print: Arrow Downword Flower Pattern Stud to Print: Enter Character ress any key to continue ress any key te continue

Explanation / Answer

// SOLUTION 1

#include <iostream>

using namespace std;

int main() {

   int numCoins[3];
   int change;
   int possi = 0;
   int a, b, c;
  
   cout << "Enter number of 5 ruppee coins: " << endl;
   cin >> numCoins[0];
  
   cout << "Enter number of 2 ruppee coins: " << endl;
   cin >> numCoins[1];
  
   cout << "Enter number of 1 ruppee coins: " << endl;
   cin >> numCoins[2];
  
   cout << "Enter the amount you want to change: " << endl;
   cin >> change;
  
   for (int i=0; i<=numCoins[0]; i++) {
       for (int j=0; j<=numCoins[1]; j++) {
           for (int k=0; k<=numCoins[2]; k++) {
               if (5*i + 2*j + 1*k == change) {
                   possi = 1;
                   a = i;
                   b = j;
                   c = k;
               }
           }
       }
   }
  
   if (possi == 1) {
       cout << "Change is possible." << endl;
       cout << "Number of 5 ruppee coins = " << a << endl;
       cout << "Number of 2 ruppee coins = " << b << endl;
       cout << "Number of 1 ruppee coins = " << c << endl;
   }
   else {
       cout << "Change is not possible." << endl;
   }
  
   return 0;
}

// SOLUTION 2

#include <iostream>
#include <string>

using namespace std;

void printHexagon(string str) {

   cout << "Here's your Hexagon." << endl;
  
   for (int i=0; i<5; i++) {
      
       for (int j=0; j<5-i; j++) {
           cout << " ";
       }
      
       for (int j=0; j<6+2*i; j++) {
           cout << str;
       }
      
       for (int j=0; j<5-i; j++) {
           cout << " ";
       }
      
       cout << endl;
   }
  
   for (int i=0; i<16; i++)
       cout << str;
   cout << endl;
  
   for (int i=0; i<5; i++) {
      
       for (int j=0; j<i+1; j++) {
           cout << " ";
       }
      
       for (int j=0; j<16-2*(i+1); j++) {
           cout << str;
       }
      
       for (int j=0; j<i+1; j++) {
           cout << " ";
       }
      
       cout << endl;
   }  
}

void printCross(string str) {
  
   cout << "Here's your Cross." << endl;
  
   for (int i=0; i<5; i++) {
      
       for (int j=0; j<11; j++) {
          
           if (j == i || j+i == 10)
               cout << str;
           else
               cout << " ";
       }
       cout << endl;
   }  
  
   for (int i=0; i<5; i++)
       cout << " ";
   cout << str << endl;
  
   for (int i=0; i<5; i++) {
      
       for (int j=0; j<11; j++) {
          
           if (j == 4-i || j == 6+i)
               cout << str;
           else
               cout << " ";
       }
       cout << endl;
   }
}

void printArrow(string str) {
  
   cout << "Here's your Downward Arrow." << endl;
  
   for (int i=0; i<8; i++) {
       for (int j=0; j<7; j++)
           cout << " ";
       cout << str << endl;  
   }
  
   for (int i=0; i<7; i++) {
       for (int j=0; j<15; j++) {
           if (j == i || j == 7 || j == 14-i)
               cout << str;
           else
               cout << " ";      
       }
       cout << endl;
   }
  
   for (int i=0; i<7; i++) {
       cout << " ";
   }
   cout << str << endl;
}

void printFlower(string str) {

   cout << "Here's your Flower." << endl;
  
   for (int i=0; i<6; i++) {
      
       for (int j=0; j<7; j++)
           cout << " ";
          
       for (int j=0; j<11; j++) {
           if (j >= 5-i && j <= 5+i)
               cout << str;
           else
               cout << " ";
       }  
       cout << endl;
   }
  
   cout << endl;
  
   for (int i=0; i<6; i++) {
  
       for (int j=0; j<25; j++) {
           if ((j >= 7 && j <= 17) || (j >= 5-i && j <= 5) || (j >= 19 && j <= 19+i))
               cout << str;
           else
               cout << " ";
       }
       cout << endl;
   }
  
   for (int i=0; i<5; i++) {
  
       for (int j=0; j<25; j++) {
           if ((j >= 7 && j <= 17) || (j > i && j <= 5) || (j >= 19 && j <= 23-i))
               cout << str;
           else
               cout << " ";
       }
       cout << endl;
   }
  
   cout << endl;
  
   for (int i=0; i<6; i++) {
      
       for (int j=0; j<7; j++)
           cout << " ";
          
       for (int j=0; j<11; j++) {
           if (j >= i && j <= 10-i)
               cout << str;
           else
               cout << " ";
       }  
       cout << endl;
   }
}

int main() {

   string str;
   int type;
  
   cout << "Enter the character: " << endl;
   cin >> str;
  
   if (str.length() > 1)
       cout << "Please enter a single character." << endl;
   else {  
       cout << "Enter 1 for Hexagon, 2 for Cross Sign, 3 for Arrow Downward, 4 for Flower Pattern." << endl;
       cin >> type;
      
       if (type == 1)
           printHexagon(str);
       else if (type == 2)
           printCross(str);
       else if (type == 3)
           printArrow(str);
       else if (type == 4)      
           printFlower(str);
   }
   return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote