Question

Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in the decimal to octal program I
When stepping through the quadruple, begin at 2 since the first character is a throw away for this program. Use 2 switch stat
using matlab
Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in the decimal to octal program Introduction: In file systems on servers (think of websites like Google, Amazon, etc.), permission to access the files come from the octal number system. Given an octal quadruple, permissions are defined for the user, the group, and other as follows: Permission First Digit Second Digit Third Digit Fourth Digit Always 01 (User-u) 0 」(Group-g) | (Other-o) Read (r) Write (w) 0 Execute (x) 0 Add the values in each column to determine the permission for the user/group/other. For example, 7, for the user gives read/write/execute permission (to get 7, you have 4+2+1 so read is given, write is given and execute is given). If user had 3 as a permission, instead, then only write/execute permissions are given (to get 3 you add 2+1 so only write is given and execute is given). If user had 6 as a permission, then 4+2 is required, which is read/write permissions. Program Details: Create a MATLAB script called octalFilePermissions.m. Prompt for a file permissions string of quadruples, outputting the file permission for user/group/other (see Sample Output). Algorithm Use a for-loop to read one permission quadruple at a time (i.e., use a stepping value of 4 in your for-loop). 1. Use a nested for-loop to step through each quadruple, determining this user's permissions: a. Create an output variable. Note that this is within the first for-loop because it needs to be reset to empty each time. Recall that a string is initialized as empty by assigning it the value [] Now, create a variable that will contain just the one quadruple. If your outer for-loop header uses i as the variable, then oneQuadruple permissions(i:(i+3)) will create a character string of the quadruple. This assumes that permissions is the name of your input variable. i. The colon in MATLAB will create a substring with i as the starting index and (i+3) as the ending index, in my example.
When stepping through the quadruple, begin at 2 since the first character is a throw away for this program. Use 2 switch statements. The first will determine whose permission: user/eroup/other. The second will determine the type of permission: ili. iv. 0: none 1: execute 2: write 3: write/execute 4: read 5: read/execute 6: read/write 7: read/write/execute v. append to your output variable Now that one quadruple has been processed, output its value and a new line (see Sample Output) b. 2. Before each significant step, provide a comment explaining the step (do not comment every line of code). Sample Output Enter file permissions 07170502047701770361037607500675065305150020006502700336061303550625 User: read/write/execute Group: execute Other: read/write/execute User: read/execute Group: none Other: write User: read Group: read/write/execute Other: read/write/execute User: execute Group: read/write/execute Other: read/write/execute User: write/execute Group: read/write Other: execute User: write/execute Group: read/write/execute Other: read/write User: read/write/execute Group: read/execute Other: none User: read/write Group:read/write/execute Other:read/execute User: read/write Group: read/execute Other: write/execute User: read/execute Group: execute Other: read/execute User: none Group: write Other: none User: none Group: read/write Other: read/execute User: write Group: read/write/execute Other: none User: write/execute Group: write/execute Other: read/write User: read/write Group: execute Other: write/execute User: write/execute Group: read/execute Other: read/execute User: read/write Group: write Other: read/execute Include header comments (at the beginning of your m-file) formatted as shown below. Your electronic submission of the program file will represent your endorsement of the Honor Code Statement
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Screenshot

5205100280065 User res writefevecute Group execute Otheriresd writerexecute Useriresd Groupreadrite/execute otherireadite exe---------------------------------------------------------------------

Program

%prompt string
inp='Enter file permissions:';
%for next line
inp=strcat(inp,char(13));
%Prompt
filePermission=input(inp,'s');
%Loop until end of the string
for i=1:i+4:length(filePermission)
   %Each time new quadruple
   quadruple='';
   %get quadruple
   for j=i:i+3
     quadruple=strcat(quadruple,filePermission(j));
   end
   %Output string
   output='';
   %Loop through quadruplt
   for n=2:length(quadruple)
     %Switch for who using
     switch n
       case 2
        output=strcat(output,'User:');
       case 3
        output=strcat(output,' Group:');
       case 4
        output=strcat(output,' Other:');
     end
     %Convert into int
     val=str2num(quadruple(n));
     %Swithch to get type of permission
     switch val
       case 0
        output=strcat(output,'none');
       case 1
        output=strcat(output,'execute');
       case 2
        output=strcat(output,'write');
      case 3
        output=strcat(output,'write/execute');
      case 4
       output=strcat(output,'read');
      case 5
        output=strcat(output,'read/execute');
      case 6
        output=strcat(output,'read/write');

    case 7
        output=strcat(output,'read/write/execute');
     end
   
   end
   %Display details
disp(output)

end

-----------------------------------------------------

Output

Enter file permissions:
071705020477017703610376075006750653051500200065
User:read/write/execute Group:execute Other:read/write/execute
User:read/execute Group:none Other:write
User:read Group:read/write/execute Other:read/write/execute
User:execute Group:read/write/execute Other:read/write/execute
User:write/execute Group:read/write Other:execute
User:write/execute Group:read/write/execute Other:read/write
User:read/write/execute Group:read/execute Other:none
User:read/write Group:read/write/execute Other:read/execute
User:read/write Group:read/execute Other:write/execute
User:read/execute Group:execute Other:read/execute
User:none Group:write Other:none
User:none Group:read/write Other:read/execute

Add a comment
Know the answer?
Add Answer to:
Programming Assignment 5: For-Loops CSCI 251-Spring 2019 This program will use the concepts in th...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. Write the command to set the following permissions on a script file with the following...

    1. Write the command to set the following permissions on a script file with the following name; myscript.sh Owner: full access; read, write and execute Group: read and execute Other: no access 2. Create a new file with the name "myfirstscript.sh". Write a new script that performs the following tasks in sequence; Display the usernames of currently logged in users; sorted from a-z HINT: You will need to filter the output of the whocommand Display a list of usernames who...

  • Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the...

    Write a Java program to convert octal (integer) numbers into their decimal number equivalents (exactly the opposite of what you have done in Assignment 4). Make sure that you create a new Project and Java class file for this assignment. Your file should be named “Main.java”. You can read about octal-to-decimal number conversions on wikepedia Assignment 4 is at the bottom Objective Your program should prompt the user to enter a number of no greater than 8 digits. If the...

  • 5.Create two files also called file file1 and file2 in testdir_2 Use the ls -lR to show you created the directories 6. Change the permission of the files in the directories below and show their permi...

    5.Create two files also called file file1 and file2 in testdir_2 Use the ls -lR to show you created the directories 6. Change the permission of the files in the directories below and show their permissions testdir/testdir_1/file1 where owner has read and execute permissions testdir/testdir_1/file2 where where owner has read, write and execute permissions. Group has read only permissions 7. Create a directory called newdir/newdir_1/newdir_2 copy the file testdir/testdir_1/file1 to this directory Change the permisions of the file to owner,...

  • Please complete in JAVA only PROBLEM: CHMOD is a command in the UNIX computer system. It...

    Please complete in JAVA only PROBLEM: CHMOD is a command in the UNIX computer system. It is the command used for giving users permissions to access and change files and directories. There are 3 classes of users. They are the owner, the group and others. The permissions given are: read(r, write(w) and execute(x). The argument of the CHMOD command is a 3-character octal number (ex. 526). When each digit of that number is converted to binary, the binary digits are...

  • Use PYTHON3 to create a program that asks the user for their name, and then prints...

    Use PYTHON3 to create a program that asks the user for their name, and then prints their initials. You must create a function called getInitials() that takes the name string and prints out the initials. It must be case insensitive and the initials must be printed in upper case. The program must contain a main() and a function called getInitials(), implemented as described in the function header comment given below. (You should include this function header comment in your own...

  • Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are...

    Programming Assignment 3 CSCI 251, Fall 2015 Infinite Series Trigonometric and math functions are usually calculated on computers using truncated Taylor series (an infinite series). An infinite series is an infinite set of terms whose sum is a particular function or expression. For example, the infinite series used to evaluate the natural log of a number is (x - 1)2 (x-1)3 (x-1)* (x-1)5 2 4 where x E (0, 2], or 0

  • I have the following code....from the previous lab....the above needs to be added to what is...

    I have the following code....from the previous lab....the above needs to be added to what is already existing. ALSO MODIFY SEMAPHORES TO USE pthreads instead of the pipe constructs P() & V() #include <stdio.h> #include <string.h> #include <sys/types.h> #include <unistd.h> #include <sys/wait.h> #include <stdlib.h> #include <sys/stat.h> void printStat(char *filename); //Main int main(int argc, char *argv[]) { //Process Id (storing)    pid_t pid;    int j;    //printf("Welcome to Project Three\n”);    // For loop*/    for (j = 1; j...

  • Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...

    Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...

  • Really need help from 11 on: Create the directory structure IFT383FinalExam/Activities/Activity1 in your home directory. Using...

    Really need help from 11 on: Create the directory structure IFT383FinalExam/Activities/Activity1 in your home directory. Using the cat command, create a file named classRoster with the following fields, separated by a comma. Student ID First Name Last Name Grade Program of Study ASURITE ID (username) Add three records to your file. Display the contents of the file. Move the file classRoster to the directory Activity1. Go to the Activity1 directory. Display the directory you are in. Add read, write and...

  • The purpose of this assignment is to create a program that works like a simple html...

    The purpose of this assignment is to create a program that works like a simple html file converter. Your program will read a text file and will produce an html file that can be viewed using a web browser, like Mozilla Firefox or Internet Explorer. Write code that converts an input file, myfile, into a simple Hyper Text Markup Language (HTML) file, myfile.html. In order to do this, you will read the input file, myfile, from the beginning to the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT