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

The Allegro Music School is preparing the program for its Spring Recital. The sc

ID: 3600107 • Letter: T

Question

The Allegro Music School is preparing the program for its Spring Recital. The school has two teachers, Ms. Smith and Mr. Jones, who teach students on a wide variety of instruments: Brass instrunents: trumpet, trombone, tuba Woodwind instruments: flute, piccolo, clarinet, oboe Keyboard instruments: organ, piano String instruments: harp, violin, viola, cello In the Spring Recital, the school wants to arrange the order of student performances to meet three criteria: I. The teachers want to have the beginning students near the beginning of the recital, the intermediate students in the middle, and the advanced students at the end. Thus, the students will be in nondecreasing order according to the number of years they have been studying their instruments: Ist year students are followed by 2nd year students, and so on. Some years may be missing (i.e., it is possible to have no 2nd year students), but you may not have an advanced student followed by a beginner 2. To ensure variety in the recital, there must not bet instruments from the s category next to each other in the recital order. That is, a brass player cannot be directly followed by another brass player, a keyboard player cannot be directly followed by another keyboard player, and so on 3. Each of the teachers (Smith and Jones) should have at least two students in the recital. For your homework, you will write a program that will take as input a proposed list of students, with their instruments, teachers, and years of study; your program must decide whether this list is an acceptable order for the recital. Examples: Example 1: Adam, Trumpet, Smith, 1 Eve, Harp, Jones, 3 Abe, Oboe, Jones, 3 Sarah, Piano, Smith, 8 This is an acceptable recital order. Example 2: Arthur, Flute, Jones, 2 Gwen, Cello, Jones, 2

Explanation / Answer

#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


class RegisterOp
{
private:
   vector<char> reg;

public:
   int size;
   RegisterOp(int si);
   int insert_register(string s1);
   int right_shift_op(int num_rs, char vvalue);
   int left_shift_op(int num_ls, char vvalue);
   int getregistersizeValue();
   void setregistersizeValue(int val);
   int print_regis();
};

RegisterOp::RegisterOp(int s1)
{
   size = s1;
}

int RegisterOp::insert_register(string s1)
{
   for (int i = 0; i < size; i++)
   {
       reg.push_back(s1[i]);
   }
   reverse(reg.begin(), reg.end());
   return 0;
}

int RegisterOp::right_shift_op(int num_rs, char vvalue)
{
   reg.erase(reg.begin(), reg.begin()+num_rs);

   for (int i = 0; i < num_rs; i++)
   {
       reg.push_back(vvalue);
   }

   return 0;
}

int RegisterOp::left_shift_op(int num_ls, char vvalue)
{
   reg.erase(reg.end()-num_ls, reg.end());
   for (int i = 0; i < num_ls; i++)
   {
       reg.insert(reg.begin(), vvalue);
   }
   return 0;
}