import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;
public class FilePermission {
// Map to hold letter file permission and equivalent deciaml value
static Map<String, String> fileMap = new HashMap<>();
private static void loadMap() {
fileMap.put("--x", "1");
fileMap.put("-w-", "2");
fileMap.put("-wx", "3");
fileMap.put("r--", "4");
fileMap.put("r-x", "5");
fileMap.put("rw-", "6");
fileMap.put("rwx", "7");
}
//Main function
public static void main(String[] args) {
// TODO Auto-generated method stub
loadMap();
//Scanner to read input
Scanner consoleInput = new Scanner(System.in);
System.out.print("Enter File Permission in Decimal Format: ");
String decinalFormat = consoleInput.nextLine();
System.out.println(decimalToBinary(decinalFormat) + " and " + decimalToLetter(decinalFormat));
System.out.print("Enter File Permission in Decimal Format: ");
decinalFormat = consoleInput.nextLine();
System.out.println(decimalToBinary(decinalFormat) + " and " + decimalToLetter(decinalFormat));
System.out.print("Enter File Permission in Binary Format: ");
String binaryFormat = consoleInput.nextLine();
System.out.println(binaryToDecimal(binaryFormat) + " and " + binaryToLetter(binaryFormat));
System.out.print("Enter File Permission in Binary Format: ");
binaryFormat = consoleInput.nextLine();
System.out.println(binaryToDecimal(binaryFormat) + " and " + binaryToLetter(binaryFormat));
System.out.print("Enter File Permission in Letter Format: ");
String letterFormat = consoleInput.nextLine();
System.out.println(latterToDecimal(letterFormat) + " and " + letterToBinary(letterFormat));
}
// TODO Auto-generated method stub
loadMap();
//Scanner to read input
Scanner consoleInput = new Scanner(System.in);
System.out.print("Enter File Permission in Decimal Format: ");
String decinalFormat = consoleInput.nextLine();
System.out.println(decimalToBinary(decinalFormat) + " and " + decimalToLetter(decinalFormat));
System.out.print("Enter File Permission in Decimal Format: ");
decinalFormat = consoleInput.nextLine();
System.out.println(decimalToBinary(decinalFormat) + " and " + decimalToLetter(decinalFormat));
System.out.print("Enter File Permission in Binary Format: ");
String binaryFormat = consoleInput.nextLine();
System.out.println(binaryToDecimal(binaryFormat) + " and " + binaryToLetter(binaryFormat));
System.out.print("Enter File Permission in Binary Format: ");
binaryFormat = consoleInput.nextLine();
System.out.println(binaryToDecimal(binaryFormat) + " and " + binaryToLetter(binaryFormat));
System.out.print("Enter File Permission in Letter Format: ");
String letterFormat = consoleInput.nextLine();
System.out.println(latterToDecimal(letterFormat) + " and " + letterToBinary(letterFormat));
}
private static String decimalToBinary(String decimalInput) {
String binaryOut = "";
//Split the input based on ,
StringTokenizer token = new StringTokenizer(decimalInput, ",");
while (token.hasMoreTokens()) {
// Get first seqment
int filePerSegment = Integer.parseInt(token.nextToken());
String tempBinary = "";
//Convert into binary
while (filePerSegment > 0) {
tempBinary = (filePerSegment % 2) + tempBinary;
filePerSegment = filePerSegment / 2;
}
//Add leading zero
while (tempBinary.length() != 3) {
tempBinary = "0" + tempBinary;
}
binaryOut = binaryOut + tempBinary + " ";
tempBinary = "";
}
return binaryOut;
}
private static String decimalToLetter(String decimalInput) {
String letterOut = "";
//String array to hold letter permision
String[] filePermission = { "---", "--x", "-w-", "-wx", "r--", "r-x", "rw-", "rwx" };
//Split the input based on ,
StringTokenizer token = new StringTokenizer(decimalInput, ",");
while (token.hasMoreTokens()) {
//Get first segment
int filePerSegment = Integer.parseInt(token.nextToken());
//GEt corresponding letter
letterOut = letterOut + filePermission[filePerSegment] + " ";
}
return letterOut;
}
private static String binaryToDecimal(String binaryInput) {
String decimalOut = "";
//Split the input based on ,
StringTokenizer st = new StringTokenizer(binaryInput, ",");
while (st.hasMoreTokens()) {
String binary = st.nextToken().trim();
int decimal = 0;
int pow = 0;
//Convert to decimal
for (int i = 2; i >= 0; i--) {
decimal += Integer.parseInt(binary.charAt(i) + "") * Math.pow(2.0, pow);
pow++;
}
decimalOut = decimalOut + decimal;
}
return decimalOut;
}
private static String binaryToLetter(String binaryInput) {
String letterOut = "";
//Convert binary to decimal
String decimalOut = binaryToDecimal(binaryInput);
String temp = "";
for (int i = 0; i <= 2; i++) {
temp = temp + decimalOut.charAt(i) + ",";
}
temp = temp.substring(0, temp.length() - 1);
//Call decimal to letter function
letterOut = decimalToLetter(temp);
return letterOut;
}
private static String latterToDecimal(String letterInput) {
String decimalOut = "";
//Split the input based on ,
StringTokenizer st = new StringTokenizer(letterInput, ",");
//Conver to decimal
while (st.hasMoreTokens()) {
String temp = st.nextToken();
decimalOut = decimalOut + fileMap.get(temp.trim());
}
return decimalOut;
}
private static String letterToBinary(String letterInput) {
String binaryOut = "";
//Call letter to decimal function to get deciaml format
String decimalOut = latterToDecimal(letterInput);
String temp = "";
for (int i = 0; i <= 2; i++) {
temp = temp + decimalOut.charAt(i) + ",";
}
decimalOut = temp.substring(0, temp.length() - 1);
// call decimal to binary to get binary value
binaryOut = decimalToBinary(decimalOut);
return binaryOut;
}
}
output
Please complete in JAVA only PROBLEM: CHMOD is a command in the UNIX computer system. It...
Objective: Practice common UNIX commands. Procedure: The following list of Unix commands are given for self-learning. Use 'whatis' or 'man' command to find out about each command. Your document should include the description or screen shots of the output from each of the command. Commands: df du gzip file history wget Changing access rights: chmod u+x Dir1.0 adds execute permission for the owner chmod go-w file1 removes write permission for the group and others chmod ugo=rw testfile sets...
Write a program in C using Unix system calls and functions that will change the permissions on a file. The executable shall be called “mychmod” and will be executed by: mychmod -u rwx -g rwx -o rwx -U rwx -G rwx -O rwx file1 file2 ... The lowercase options will add permissions while the uppercase options will remove permissions. Each of the switches is optional and should be interpreted as the ones in the Unix command chmod(1), you can review...
please need assistance on part B of the question b) A planar manipulator has link lengths L1 2m and L2-1 m.Use the inverse kinematic equations to find the joint angles which will place the end point at the following positions (x V2 i) Write the forward kinematic equations for the end point. [2 marks] ii) Calculate the link L2 joint angle iii) Calculate the link L1 joint angle [5 marks] [5 marks] [Q1 Total: 20 Marks] Question 2 a) Explain...
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...
You will use Quartus II to build an 8 bit arithmetic logic unit that performs the following functions: Control Value Function 000 Copy In1 to theResult unchanged 001 Copy In2 to theResult unchanged 010 Add In1 to In2 011 Subtract In2 from In1 100 And In1 and In2 101 Or In1 and In2 110 Shift left In1 by 1 bit 111 Shift right In1 by 1 bit You are allowed to use either gates/logic schematic, or else Verilog. We suggest...
III. ASSIGNMENT 2.1 As discussed in class, the example program enumerates all possible strings (or if we interpret as numbers, numbers) of base-b and a given length, say l. The number of strings enumerated is b l . Now if we interpret the outputs as strings, or lists, rather than base-b numbers and decide that we only want to enumerate those strings that have unique members, the number of possible strings reduces from b l to b!. Furthermore, consider a...