Write a C program that reads three integers and then prints them in the order read and reversed. Use four functions: main, one to read the data, one to print them in the order read, and one to print them reversed.
In: Computer Science
Someone once said, "if you gave everyone in the world a million dollars and if you waited long enough then 1 person would have all the money and everyone else would have nothing". You are going to write a program to test truthfullness of that statement.
Repeat the following actions until nActive equals 1:
using this code
#include "fixed1dintarray.h"
fixed1dintarray::fixed1dintarray(int newnelts)
{
if (newnelts < 2)
newnelts = 16;
size = newnelts;
nelts = 0;
elts = new int[size];
}
bool fixed1dintarray::isEmpty()
{
return nelts == 0;
}
bool fixed1dintarray::isFull()
{
return nelts == size;
}
int fixed1dintarray::getsize()
{
return size;
}
int fixed1dintarray::getnelts()
{
return nelts;
}
bool fixed1dintarray::getelt(int where, int& elt)
{
bool isgood = 0 <= where && where < nelts;
if (isgood)
elt = elts[where];
return isgood;
}
bool fixed1dintarray::member(int value)
{
return find(value) >= 0;
}
int fixed1dintarray::find(int value)
{
int pos = 0;
//while(!(pos < nelts || elts[pos] == value))
//until(pos == nelts || elts[pos] == value)
while (pos < nelts && elts[pos] != value)
pos++;
if (pos < nelts)
return pos;
else
return -1;
}
bool fixed1dintarray::insat(int where, int elt)
{
if (isFull())
return false;
if (where < 0 || nelts < where)
return false;
for (int pos = nelts - 1; pos >= where; pos--)
elts[pos + 1] = elts[pos];
elts[where] = elt;
nelts++;
return true;
}
bool fixed1dintarray::append(int elt)
{
return insat(nelts, elt);
}
bool fixed1dintarray::delat(int where)
{
if (where < 0 || nelts <= where)
return false;
for (int pos = where + 1; pos < nelts; pos++)
elts[pos - 1] = elts[pos];
return false;
}
bool fixed1dintarray::delelt(int elt)
{
int where = find(elt);
return delat(where);
}
void fixed1dintarray::show()
{
for (int i = 0; i < nelts; i++)
cout << elts[i] << ' ';
}
In: Computer Science
Write a program that asks a user how many classes they are taking this term, the name of each class, the credit hours for each class, and their final letter grade for each class, and then calculates their term GPA. Use either a list for each course or a single list-of-lists. The grading system and examples can be found on the TAMU website: http://registrar.tamu.edu/Transcripts-Grades/How-to-Calculate-GPA
In: Computer Science
Writing a caesar cipher in ARM assembly.
INSTRUCTIONS:
Step 1:
The first thing you should do is modify the case conversion program String.s (provided)
Instead of subtracting 32 from all numbers you want to add a constant number which we will call the key.
Assume that all input will be lowercase.
So it'll look like this,
k = 2;
letter = 'a';
newletter = k+letter;
Above is pseudocode and ABOVE NOT ASSEMBLY CODE DO NOT COPY.
Use bl puts to show that everything is working correctly.
You should hard code the plaintext in the assembly file.
Step 2:
If the key + letter is bigger is 'z' then you have to subtract 26.
If the key + letter is less than 'a' then you have to add 26.
STRING.S
.text
.global main
main:
ldr r4,=string
get_another_byte:
ldrb r5,[r4]
cmp r5,#'a'
# blt keep_going
# cmp r5,#'z'
# bgt keep_going
subeq r5,#32
strbge r5,[r4]
keep_going:
add r4,#1
cmp r5,#0
bne get_another_byte
ldr r0,=temp
str lr,[r0]
ldr r0,=string
bl puts
ldr r0,=temp
ldr lr,[r0]
bx lr
.data
string:
.asciz "This is a string"
temp:
.word 0In: Computer Science
import java.util.*;
import java.security.*;
import javax.crypto.*;
import java.nio.file.*;
public class CryptoApp {
public static void main(String[] args) throws Exception {
Crypto crypto = new BasicCrypto();
String welcome = "Hello
2043-er's! Let's try this again :-)";
System.out.println(welcome);
// First, where are we?
//Let's print out our current working directory
Path cwd =
FileSystems.getDefault().getPath("").toAbsolutePath();
System.out.println("Current Working Directory: " + cwd);
// Read in our file to encrypt
byte[] originalData =
Files.readAllBytes(Paths.get(System.getProperty("user.home"),
"C-2044-Sample/Crypto/src/encrypt.txt"));
// Encrypt it and save into a byte array
byte[] encryptedData = crypto.encrypt(originalData);
// Decrypt it and save it into
another byte array
byte[] decryptedData = crypto.decrypt(encryptedData);
// Write the encrypted text into the original file
Files.write(Paths.get(System.getProperty("user.home"), "test"),
encryptedData);
// Write the decrypted text into the decrypted text file
Files.write(Paths.get(System.getProperty("user.home"),
"C-2044-Sample/Crypto/src/decrypt.txt"), decryptedData);
String sendoff = "It's a wrap!";
System.out.println(sendoff);
}
}
Ok so for this code I changed the name of the file from java-2022 to C-2044 to intentionally create an exception.
Exception in thread "main" java.nio.file.NoSuchFileException: /home/runner/C-2044-Sample/Crypto/src/encrypt.txt
so how would I write a try/catch/finally cause to catch one or more specific exception objects.
In: Computer Science
In C programming. If a grammatically correct input is entered,
the program should convert the two
strings to two integer arrays and perform the given operation on
each array location.
For all operations, consider each corresponding array position
independently (e.g.,
there are no carries). The resulting array should then be converted
back to a string,
and finally printed. If the two input strings are not the same
length, then each output
character beyond the length of the shorter string should be a copy
of the character
from the longer string with the opposite case.
The mathematical operations work as follows. Each symbol should be
converted to
an integer as shown in the table to the right (i.e., a is 0, b is
1, c is 2, …, U is 46).
This mapping forms a finite field, and we can define addition and
multiplication on
this field.
Symbol Value
a 0
b 1
... ...
z 25
A 26
B 27
... ...
T 45
U 46
Page 2 of 3
Addition on a finite field: +
For this operation, for each array position find the sum of the two
integers and if the result is larger than
46 find the remainder when the quotient is 47. That is, find (? +
?) ??? 47. For example, if the user
enters:
> abc+bbc
the result that should be printed is
'abc' + 'bbc' => 'bce'
> tuvwx+CBAzy
'tuvwx' + 'CBAzy' => 'aaaaa'
For this example the first string is longer than the second (the
'e' in orange). The output corresponding
to this extra symbol is 'E':
> orange+white
'orange' + 'white' => 'KyiGkE'
Multiplication on a finite field: *
This operation is handled the same way as addition but uses modular
multiplication. That is, find
(? × ?) ??? 47.
> abcqH*AUydkzAB
the result that should be printed is
'abcqH' * 'AUydkzAB' => 'aUbbbZab'
> yyyyyyyyyyyy*abcdefghijkl
the result that should be printed is
'yyyyyyyyyyyy' * 'abcdefghijkl' => 'aybzcAdBeCfD'
Inversion on a finite field: /
For this operation, given two numbers X / Y, find a number Z such
that ? = (? × ?) ??? 47. However,
if Y is zero, then this operation is undefined, so set the output
to zero.
> abcqHU/Aabdk
the result that should be printed is
'abcqHU' / 'Aabdk' => 'aacviu'
> bbbbb/ABCDU
the result that should be printed is
'bbbbb' / 'ABCDU' => 'MhQnU'
In: Computer Science
MATLAB
Create a function that prints a string of perfect cubes between (m,n). Include any reasonable error statements such as decimals and negative numbers.
In: Computer Science
Sorting and Searching
Given an unsorted array numbers of integers with duplicate values. Sort the array and remove the duplicates in-place such that each element appears only once in the input array and returns the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Find the time complexity of your removeDuplicates() method in Big-O notation and write that in a comment line on the top of your code.
Hints: Sort the array before finding the number of unique elements. You can use any sorting algorithm that you have learned in the class. Do not use the built-in sorting algorithm of java.
Clarification:
Confused why the returned value of removeDuplicates() method is an integer but your answer is an array?
Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller (main() method) as well.
Example 1:
Input: {1, 2, 1}
Output: {1, 2}
Your removeDuplicates() method should return length = 2, with the two unique elements of numbers being 1 and 2. It doesn't matter what you leave beyond the returned length.
Example 2:
Input: {2, 1, 0, 1, 2, 0, 3, 3, 2, 1}
Output: {0, 1, 2, 3}
Your removeDuplicates() method should return length = 4, with the four unique elements of numbers are 0, 1, 2, and 3. It doesn't matter what values are set beyond the returned length.
USE THIS CODE:
import java.util.Scanner;
class Main {
// add your sorting algorithm code here
public static int removeDuplicates(int[] numbers){
// your code goes here for removing duplicates
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.print("Enter the size of the array > ");
int n = scan.nextInt();
int[] numbers = new int[n];
System.out.print("Enter the array elements with duplicates in it
> ");
for(int i = 0; i < n; i++){
numbers[i] = scan.nextInt();
}
int len = removeDuplicates(numbers);
for(int i = 0; i < len; i++)
System.out.print(numbers[i] + " ");
System.out.println();
scan.close();
}
}
In: Computer Science
Case-IT Auditing
ABC has a sound change management process/policy for program code changes that includes the ability for users to request changes which are entered by users through a web based internally managed portal (CMP)ICS). User requests are then electronically routed to the appropriate IT and business personnel for review and approval to proceed to work the request. Once IT completes the coding revisions and performs unit and system testing, then users will test the system changes. Upon satisfactory testing the users will formally approve the movement of code to production using the web-based change portal. IT will then work with the business areas to move the code from the test environment to production at the agreed to time. All testing support is retained. ABC IT department maintains a downtime window on Sundays that allow time for code migrations. Additionally, this same downtime window allows for appropriate full backups to occur for all systems. During the week incremental backups occurs.
Question: What are the Controls and what are the GAPS
In: Computer Science
You are now the manager of a small team of software engineers. Some of them are fresh graduates, while some of them have a few years of working experience in the field. You are tasked with producing a small experimental FinTech (Financial Technology) mobile application. You will need to publish on both Android and iPhone platforms. You are adopting an Agile methodology, with emphasis on Test-Driven Development and extensive automated tests. The concept behind the application is very innovative, so the design is constantly changing.
One of your new team members, Ken, is a top CS graduate with a 4.0 GPA and he claims he never produces bugs in his programs. He thus proposes that he won't be adopting the Test-Driven Development methodology that the team is using. As a manager, will you agree with his proposal? Why/why not?
In: Computer Science
Case-IT Auditing
Code developers modify or create programs. The IT testing team performs all internal IT testing; however, the business areas perform their own user acceptance testing. The IT Departments Middleware team is responsible for migrating all code to production (except for database triggers). The Middleware Team does not perform any code development activities. Although SQL database triggers are developed or modified by code developers, the migration for the triggers is performed by the Database Administrators from test databases to production databases since this code development is specific database centric. Question: What are the Controls and what are the GAPS.
Question: What are the Controls and what are the GAPS
In: Computer Science
Case-IT Auditing
Once a user enters a request, the internal workflows based on the information downloaded from CBHR will be used to route the request to the user’s manager. Privileged access requests are also routed to the CIO for a secondary approval. The requestor’s manager will receive an email notification of a new access request to approve and will then approve the request using ABCR. Once approved the request is routed to the ABC’s IT helpdesk who processes the request. Upon completion an email notification through ABCR occurs notifying the user that their request was completed. The Company’s IT helpdesk is short staffed so it may take a few days for completion of an access request upon initiation of the request. However, the accuracy of completion is 97% regardless of time to complete.
Question: What are the Controls and what are the GAPS
In: Computer Science
In strictly three or less lines state if invisible watermarking can be used as a fool-proof method for digital copy prevention and control.
In: Computer Science
Case- IT Auditing
Windows servers are used for all server types (application, web and database delivery). Windows patch updates comply with the change management policy. Windows patches are downloaded to a central patch server. All patches are reviewed and tested prior to deployment to production servers. All approved patches are first deployed to the development servers, then to the test servers and finally to production servers. Although patches occur on Wednesday evening, if a system reboot is required these are not perform until the weekend downtime window. Approval is not required for patch updates for these are considered a normal standard process for ABC. Additionally, prior to deployment all patches are reviewed to ensure they will function with current systems.
Question: What are the Controls and what are the GAPS
In: Computer Science
Client must support load-test mode, in this mode, echo client opens a number of concurrent connections, sends a predefined message on each connection, waits for echo message back from server, and records time. User should be able to specify total number of messages to be sent concurrently from client.
Here is an example run of new mode
$python advanced_echo.py load_test 1000
Above, should cause client to attempt 1000 connections CONCURRENTLY, send predefined message, wait for echo back and record time it took each of 1000 connections to close.
Output of client should look like:
CON-1: duration: 20ms
CON-2: duration: 19ms
In: Computer Science