AccessLevel Editor 1 #include #include 4 string can_access(vector &user_rights, int min_permission) £ 6 for(int i-0; i < user_rights.sizeO-1 i++) Problem Statement In many computer systems and networks, different users are granted different levels of access to different resources. In this case, you are given a vector user_rights , indicating the privilege level of each user to use some system resource. You are also given int min_permission, which is the minimum permission a user must have to use this resource string p = ""; 7-if(user_rights.at(i) < min_permission)1 cout << p + "D" else if(user_rights.at(i) > min_permission)í 10 cout << p + "A"; You are to return a string indicating which users can and cannot access this resource. Each character in the return value corresponds to the element of users with the same index. 'A' indicates the user is allowed access, while 'D' indicates the user is denied access 12 13 14 Constraints user_rights will contain between 0 and 50 elements (0 s user_rights.sizeO s 50), inclusive .Each element of user_rights will be between 0 and 100, inclusive min_permission will be between 0 and 100, inclusive Examples 10,1,2,3,4,5 2 Returns: "DDAAAA" Here, the first two users don't have sufficient privileges, but the remainder do Test Submit

Question

I need guidance on this, more so what direction do I take to append to a string and make sure it is returning the string value?

AccessLevel
Editor
1 #include <string>
#include <vector>
4 string can_access(vector<int> &user_rights, int min_permission) £
6 for(int i-0; i < user_rights.sizeO-1 i++)
Problem Statement
In many computer systems and networks, different users are granted
different levels of access to different resources. In this case, you are given
a vector<int> user_rights , indicating the privilege level of each user to
use some system resource. You are also given int min_permission, which
is the minimum permission a user must have to use this resource
string p = "";
7-if(user_rights.at(i) < min_permission)1
cout << p + "D"
else if(user_rights.at(i) > min_permission)í
10
cout << p + "A";
You are to return a string indicating which users can and cannot access
this resource. Each character in the return value corresponds to the
element of users with the same index. 'A' indicates the user is allowed
access, while 'D' indicates the user is denied access
12
13
14
Constraints
user_rights will contain between 0 and 50 elements (0 s
user_rights.sizeO s 50), inclusive
.Each element of user_rights will be between 0 and 100, inclusive
min_permission will be between 0 and 100, inclusive
Examples
10,1,2,3,4,5 2
Returns: "DDAAAA"
Here, the first two users don't have sufficient privileges, but the
remainder do
Test
Submit
Expand
Transcribed Image Text

AccessLevel Editor 1 #include <string> #include <vector> 4 string can_access(vector<int> &user_rights, int min_permission) £ 6 for(int i-0; i < user_rights.sizeO-1 i++) Problem Statement In many computer systems and networks, different users are granted different levels of access to different resources. In this case, you are given a vector<int> user_rights , indicating the privilege level of each user to use some system resource. You are also given int min_permission, which is the minimum permission a user must have to use this resource string p = ""; 7-if(user_rights.at(i) < min_permission)1 cout << p + "D" else if(user_rights.at(i) > min_permission)í 10 cout << p + "A"; You are to return a string indicating which users can and cannot access this resource. Each character in the return value corresponds to the element of users with the same index. 'A' indicates the user is allowed access, while 'D' indicates the user is denied access 12 13 14 Constraints user_rights will contain between 0 and 50 elements (0 s user_rights.sizeO s 50), inclusive .Each element of user_rights will be between 0 and 100, inclusive min_permission will be between 0 and 100, inclusive Examples 10,1,2,3,4,5 2 Returns: "DDAAAA" Here, the first two users don't have sufficient privileges, but the remainder do Test Submit

Expert Answer

Want to see the step-by-step answer?

Check out a sample Q&A here.

Want to see this answer and more?

Experts are waiting 24/7 to provide step-by-step solutions in as fast as 30 minutes!*

*Response times may vary by subject and question complexity. Median response time is 34 minutes for paid subscribers and may be longer for promotional offers.
Tagged in
Engineering
Computer Science

Related Computer Science Q&A

Find answers to questions asked by students like you.

Q: Write a program called Convert, which converts an ASCII code to its equivalentcharacter. 1) Create a...

A: Java codeimport java.util.Scanner; public class Convert{public static void main(String[] args) {Scan...

Q: The figure below shows an ER schema for a university database. Map this ER schema into a relational ...

A: Since the question refers to a mapping algorithm which is not described in the question we are going...

Q: Suppose that data are stored on 8.54-gbyte single-sided, double-layer dvds that weigh 15 g each. sup...

A: Data stored on DVDs = 8.54 GbyteWe have to calculate data transmission rate in bits per second, so w...

Q: Thank you!C++ please

A: First we'll create a LinkedList class.Below is the code for the LinkedList class:-class LinkedList{p...

Q: Find an nfa that accepts the complement from L (ab∗aa + bba∗ab)?

A: Solution:The following graph indicates the NFA (Non-deterministic finite automata) is given below:M ...

Q: Associate each of the following concepts with one of the languages we covered (pseudo code,FORTRAN, ...

A: Associating languages with given concepts:ALGOL 60: Pass by nameALGOL 60: Pass by valueFORTRAN: Assi...

Q: 1. What is the output of the following code? public class Loopy {public static void main(String[] ar...

A: 1. Algorithm for the given code is as follows:The variable ""x is initialized as "1" within the "mai...

Q: Show that there exists an algorithm to determine whether λ ∈ L for any regular language L.

A: DFA (Deterministic Finite Automation):For a given state on a given input, user reach to a determinis...

Q: create a python program that will ask users to input four different manufacturers of cars(e.g Ford, ...

A: Create a class Car and define _init_ () function which will initialize the value of variables manufa...

Q: 2. Write a program called ListOddNumbers that prints the below (there is a single space between each...

A: Solution: 2. The below program is written in Java language to display the odd number between 1 and 5...

Q: Write a program in Eclipse that prompts the user to enter a string and displays the number of vowels...

A: Solution:Given data, The java code gets the input string from user and display the number of vowels ...

Q: When working with database entity relationship modeling, should the cardinality between entities be ...

A: Cardinality: The maximum or minimum number of elements allowed on each side of the relationship in t...

Q: use java Develop a program which allows the user to enter numbers into an array. Input will be as fo...

A: Program plan:Import the required packages.Define a class named “ArraySort”.Define a “main()” method....

Q: For the following problem please write an algorithm in plain English .i.e give details as to how you...

A: Algorithm to arrange the deck of 52 cards for the given scenario is as follows:  

Q: How to implement a pluggable Adapter design pattern in Java?

A: Let’s say we have a client class called Client.java which calls method1( ) of an existing library cl...

Q: Function Name: comboLock Parameters: num1 – a positive integer representing the first digit in the c...

A: Solution: The following function checks whether the five integers is in the order (odd, even, odd, e...

Q: define virtual memory

A: Virtual memory, in context with computing, is memory management technique that is used by the operat...

Q: Prove that the following languages are not regular: (b) L = {anblak : k ≠ n + l}.

A: First, assume the given language is regular.Then apply pumping lemma to prove the statement is not r...

Q: Which filenames would be a subsequent ls command display?$ lsabc abd abe abf abg abh$ rm abc ab*rm: ...

A: To describe which filenames the subsequent ls command display.

Q: Write a function for the Superman ride at Six Flags that determines whether the user is taller than ...

A: Program code to write a function for the Superman ride  to determines whether the user is taller tha...

Q: Function #2: largest Parameters: num1 - a floating point number being compared against num2 and num3...

A: Solution:largest() function:#Define the functiondef largest(num1, num2, num3):    #Check if "num1" i...

Q: How can I create a decoder and a multiplexer in a circuit? The decoder has a 3 bit select input and ...

A: A decoder is a circuit which has n inputs and 2n outputs. So if there are 3 inputs to a decoder it w...

Q: Write a PL/SQL block to retrieve and display the students enrolled in a course.

A: Click to see the answer

Q: how to write a function in python 3 using for loop that counts how many times a consonant (either lo...

A: Note: The given program is compiled and executed in "repl.it" online compiler.

Q: a. Assuming that x is 1, show the result of the following Boolean expressions.(true) &amp;&amp; (3 &...

A: Hey, since there are multiple sub-part posted, we will answer first three sub-part. If you want any ...

Q: I was asked to add the three types of comments to this class, each consisting of the same statement ...

A: Java documentation comment: This comment is used to create documentation API. The syntax for this co...

Q: 4-20) (Process a string) Write a program that prompts the user to enter a string and displays its le...

A: Program to enter string by the user to displays string length and its first character. as in the giv...

Q: 5-13) Find the largest n such that n cubed is less than a positive integer entered by the user. Use ...

A: The heart of the algorithm lies in finding such a number whose cube is less than the given number he...

Q: Design a modular program that asks the user to enter the monthly costs for the following expenses in...

A: We are designing the program in C++ programming language. Given below is the program designed to ent...

Q: Complete the following list comprehensionlc5 = [ for c in 'bu be you']so that it produces...

A: Let’s define a python function which outputs True if the alphabet is ‘b’ or ‘u’, because the above l...

Q: how to to assign charather to perform additions (+), subtractions (-), multiplications (*), division...

A: Program plan:Include necessary header files.Declare the “namespace”.Define the “main()” function.Dec...

Q: example:"apple-&gt;orange-&gt;banana-&gt;pear"-&gt;NULLreturn "orange"Thanks!

A: ApproachIn the function longest(), we'll declare an integer named highestLength and assign 0 to it.N...

Q: Draw a half-adder using only NAND gates.

A: Half adder is basically a combinational circuit which executes simple basic addition of two binary n...

Q: Construct a dfa that accepts the language generated by the grammar S → abA, A → baB, B → aA|bb.

A: Deterministic finite automata (DFA):

Q: I was asked to add the three types of comments to this class, each consisting of the same statement ...

A: Java documentation comment: This comment is used to create documentation API. The syntax for this co...

Q: 6. Write a class with a constructor that accepts a String object as its argument. The class should h...

A: Two java.util classes are used – Scanner and Arrays. Scanner is used to read input string and Arrays...

Q: Write a complete C++ program that does the following: 3. Create a function called findSmallestValue ...

A: To use  functions, first of all  you need to declare the functions and to input the number of rows a...

Q: Create a new file in C++ and save it as lab12_XYZ.cpp  Consider rolling two six-sided dice. Whil...

A: Program Instructions:Declare the header files, constants, and prototypes.In main() call functions di...

Q: Write a program to decipher a numeric code in C++. After years of searching, your team has uncovered...

A: Program Instructions:Add header file and the required comments.Declare variables original_number and...

Q: I am trying to get the range of bits from a number. For example , if I call bitRange(0x00001234, 0 ,...

A: Step 1: To extract the bits from the hexadecimal number we need to use the shift operator and use bi...

Q: One acre of land is equivalent to 43,560 square feet. Write a program that calculates the number of ...

A: The algorithm for the program is as follows:Accept input string as the square feetCalculate the numb...

Q: Financial Application:• Write a program that computes future investment value at a given interest ra...

A: Program plan:Import necessary packages.Define a class named “Investment”.Define a method named “comp...

Q: write a program in c++. You work for a box company, and have been asked to write a program to compar...

A: Click to see the answer

Q: 5-27) (Display leap years) Write a program that displays all the leap years, ten per line, from two ...

A: Note: The below program has been complied and executed in NetBeans IDE 8.2

Q: c++ Write a program to swap the contents of two arrays. Each array has five elements. The fist array...

A: Program Instructions:Declare and initialize array and variables.Print the elements of arrays before ...

Q: Is the following distributive law valid or invalid? Prove your answer. x XOR (y + z) = (x XOR y) + ...

A: Answer:Here, the truth table is used to get the answer for each side of the question.First take LHS,

Q: Construct an unambiguous grammar equivalent to the grammar in  S→AB|aaaB, A→a|Aa, B→b.

A: Solution: Construct an unambiguous grammar to grammar.Given that,S -&gt; AB|aaaBA -&gt; a|AaB -&gt; ...

Q: do big data could replace the artistic vision of a creative director? and why?

A: Justification:“Yes”, big data replace the artistic vision of a creative director.

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz =2; y = z + x;...

A: Call by reference The arguments passed to a function will copy the address of an argument into the f...

Q: What form of storage doses a password manger store encrypted passwords? Is it local, web sites, clod...

A: Passwords managers allows one to generate strong and unique passwords and store them in one safe pla...