How does version control fit into the daily activities during a sprint?
In: Computer Science
Send an element from 2d array to a function using pointer to pointer. c++
I am having an issue with being able to send specific elements to the swap function.
#include <iostream>
using namespace std;
void swap(int **a, int **b){
int temp = **a;
**a=**b;
**b=temp;
}
void selSort(int **arr, int d){
for(int i =0; i<d-1; i++){
int min = *(*arr+i);
int minin = i;
for(int j =i+1; j<d; j++){
if(*(*arr+j)
< min){
min = *(*arr+j);
minin = j;
}
swap(*&(arr+i),*&(arr+minin));
}
}
}
int main() {
int array[2][2] = {4,3,2,1},
*ptr = &array[0][0],
**pptr = &ptr;
int size = sizeof(array)/sizeof(int);
for(int i =0; i<size; i++){
cout
<<*(*pptr+i)<<endl;
}
selSort(pptr, size);
for(int i =0; i<size; i++){
cout
<<*(*pptr+i)<<endl;
}
return 0;
}
In: Computer Science
Practice Coding Task
C++ ATM Machine with Some Classes
Create an ATM machine in C++ with a few classes.
Requirements:
Automated Teller Machine (ATM) simulationGiven 3 trials, the user
is able to see his balance by entering a four-digit pin that must
NEVER be displayed on screen but masked by the Asterix (*)
character. A list of pins stored on the file system must be loaded
to verify the pin. The user should be able to withdrawfundsbelow a
set limit and cannot redraw more than 3 times within a space of 5
minutes. The balance from each pin should be determined each time
the program is run and is a random value between 0 and 100. The
user should also be allowed to change his pin at any time which
should be reflected in the file system.
In: Computer Science
Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
In C language
Please display results
The Euclidean algorithm is a way to find the greatest common divisor of two positive integers, a and b. First let me show the computations for a=210 and b=45.
Divide 210 by 45, and get the result 4 with remainder 30, so 210=4·45+30.
Divide 45 by 30, and get the result 1 with remainder 15, so 45=1·30+15.
Divide 30 by 15, and get the result 2 with remainder 0, so 30=2·15+0.
The greatest common divisor of 210 and 45 is 15.
Formal description of the Euclidean algorithm
Input Two positive integers, a and b.
Output The greatest common divisor, g, of a and b.
Internal computation
1. If a<b, exchange a and b.
2. Divide a by b and get the remainder, r. If r=0, report b as the GCD of a and b.
3. Replace a by b and replace b by r. Return to the previous step.
Your assignment is to write an assembler code (gcd.s) that asks the user two positive numbers and calculates their greatest common denominator.
For example, you program should produce the following outputs:
Enter first positive integer: 6
Enter second positive integer: 8
The GCD is 2
In: Computer Science
Use a switch statement to create a menu with the following options
For now just print a message prompting user for input and allowing them to return the menu. No functionality is required at this time, but save this code for later use.
In: Computer Science
Java queue linked list
/*
* Complete the enqueue(E val) method
* Complete the dequeue() method
* Complete the peek() method
* No other methods/variables should be added/modified
*/
public class A3Queue {
/*
* Grading:
* Correctly adds an item to the queue - 1pt
*/
public void enqueue(E val) {
/*
* Add a node to the list
*/
}
/*
* Grading:
* Correctly removes an item from the queue - 1pt
* Handles special cases - 0.5pt
*/
public E dequeue() {
/*
* Remove a node from the list and
return it
*/
return null;
}
/*
* Grading:
* Correctly shows an item from the queue - 1pt
* Handles special cases - 0.5pt
*/
public E peek() {
/*
* Show a node from the list
*/
return null;
}
private Node front, end;
private int length;
public A3Queue() {
front = end = null;
length = 0;
}
private class Node {
E value;
Node next, prev;
public Node(E v) {
value = v;
next = prev =
null;
}
}
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
public class A3Driver {
public static void main(String[] args) {
A3DoubleLL list = new
A3DoubleLL<>();
for(int i = 1; i < 10; i++)
{
list.add(i);
}
System.out.println("Before
Swap");
System.out.println(list.printList());
System.out.println(list.printListRev());
list.swap(4);
System.out.println("After
Swap");
System.out.println(list.printList()
+ ":1,2,3,4,6,5,7,8,9,");
System.out.println(list.printListRev() +
":9,8,7,6,5,4,3,2,1,");
System.out.println();
System.out.println("Hot
Potatoe");
A3CircleLL hotPotato = new
A3CircleLL();
hotPotato.playGame(5, 3);
System.out.println("Correct:");
System.out.println("Removed Player
4\nRemoved Player 3\nRemoved Player 5\nRemoved Player 2\nWinning
player is 1");
System.out.println();
A3Queue queue = new
A3Queue<>();
queue.enqueue(5);
queue.enqueue(20);
queue.enqueue(15);
System.out.println(queue.peek()+":5");
System.out.println(queue.dequeue()+":5");
queue.enqueue(25);
System.out.println(queue.dequeue()+":20");
System.out.println(queue.dequeue()+":15");
}
}
In: Computer Science
1. To keep track of vendors and products they supply, XYZ Corp. uses the table structure shown below. Assuming that the sample data are representative, draw a dependency diagram in Visio that shows all functional dependencies including both partial and transitive dependencies. (Hint: Look at the sample values to determine the nature of the relationships.)
PART_CODE |
PART_DESC |
VEND_NAME |
VEND_ADDRESS |
VEND_TYPE |
PRICE |
1234 |
Logic Chip |
Fast Chips |
Cupertino |
Non-profit organization |
25.00 |
1234 |
Logic Chip |
Smart Chips |
Phoenix |
Non-profit organization |
22.00 |
5678 |
Memory Chip |
Fast Chips |
Cupertino |
Profit organization |
18.00 |
5678 |
Memory Chip |
Quality Chips |
Austin |
Profit organization |
15.00 |
5678 |
Memory Chip |
Smart Chips |
Phoenix |
Profit organization |
19.00 |
2. Using the initial dependency diagram drawn in question 1, remove all partial dependencies, draw the new dependency diagrams in Visio, and identify the normal forms for each table structure you created.
3. Using the table structures you created in question 2, remove all transitive dependencies, and draw the new dependency diagrams in Visio. Also identify the normal forms for each table structure you created. If necessary, add or modify attributes to create appropriate determinants or to adhere to the naming conventions.
4. Using the results of question 3, draw the fully labeled Crow's Foot ERD in Visio. The diagram must include all entities, attributes, and relationships. Primary keys and foreign keys must be clearly identified on the diagram.
In: Computer Science
in JAVA please
Some of the characteristics of a book are the title, authors, publisher, ISBN, price, and year of publication. Design the class Book so that each object can hold the following information about a book: title, up to four authors, publisher, ISBN, price, and number of copies in stock. To keep track the number of authors, you can add a variable; Including the methods to perform various operations on the objects of book. For example, the usual operations that can be performed on the title are to show the title, set the title, and check whether a title is an actual title of the book. In the similar way, the typical operations that can be performed on the number of copies in stock are to show the number of copies in stock, set the number of copies in stock, update the number of copies in stock, and return the number of copies in stock. Add similar operations for the publisher, ISBN, book price, and authors. Add the appropriate constructors. Write the definitions of the methods of the class Book based on the instruction in a). Write a program that uses the class Book and test various operations on the objects of class Book. Say declare an array of 100 components of the type book. Some the operations that you should perform are to search for a book by its title, search by ISBN, and update the number of copies of a book.
In: Computer Science
Try to make it as simple as you can and explain as much as it needed.
Ans:
Ans:
Ans:
Ans:
Ans:
In: Computer Science
Hi. I'm trying to write a program that uses dynamic memory management to create two arrays. splice() must create the third array and return a pointer to main(). Main() must capture the pointer returned from the splice() function.
Sol'n so far, I get the results of the first and second array, but it isn't showing the results of the spliced function:
#include <iostream>
using namespace std;
// Function int* splice() inserts the 2nd array into 1st array
starting at int numOfElements
int* splice(int *array1, int *array2, int size1, int size2, int
numOfElements)
{
int *result = new int[size1 + size2];
for (int i = 0; i < numOfElements; i++)
*(result + i) = *(array1 +
i);
for (int i = 0; i < size2; i++)
*(result + numOfElements + i) =
*(array2 + i);
//Line 13 will copy ith element of the second element
into numOfElements + ith position in the final array.
for (int i = numOfElements; i < size1; i++)
*(result + size2 + i) = *(array1 +
i);
system("pause");
return result;
}
int main()
{
int size1, size2, numOfElements;
cout << "Enter the size of the first array:
";
cin >> size1;
cout << "Enter the size of the second array:
";
cin >> size2;
cout << "Enter the number of elements of the
first array to be copied before splice: ";
cin >> numOfElements;
srand(100);
int *array1 = new int[size1];
int *array2 = new int[size2];
for (int i = 0; i < size1; i++)
*(array1 + i) = rand() %
size1;
for (int i = 0; i < size2; i++)
*(array2 + i) = rand() % size2;
cout << "The contents of the first array is: " <<
endl;
for (int i = 0; i < size1; i++)
{
cout << *(array1 + i)
<< "\t";
if ((i + 1) % 10 == 0)
cout <<
endl;
}
cout << endl << "The contents of the
second array is: " << endl;
for (int i = 0; i < size2; i++)
{
cout << *(array2 + i)
<< "\t";
if ((i + 1) % 10 == 0)
cout <<
endl;
}
int *array = splice(array1, array2, size1, size2,
numOfElements);
cout << "The contents of the spliced array is: " <<
endl;
for (int i = 0; i < size1 + size2; i++)
{
cout << *(array + i) <<
"\t";
if ((i + 1) % 10 == 0)
cout <<
endl;
}
delete[] array1;
delete[] array2;
delete[] array;
//the values are deleted, but the pointers still
exist
}
In: Computer Science
What is BGP? Explain how a network administrator of an upper-tier ISP can implement policy when configuring BGP.
In: Computer Science
1) Provide the type and assembly language instruction for the following binary value: 0000 0010 0001 0000 1000 0000 0010 0000 (two)
2) Provide the type, assembly language instruction, and binary representation of instruction described by the following MIPS fields: op=0, rs=3, rt=2, rd=3, shamt=0, funct=34
3)For the following C statement, write a minimal sequence of MIPS assembly instructions that does the identical operation. Assume $t1 = A, $t2 = B, and $s1 is the base address of C. A = C[0] << 4;
4) Consider the following MIPS loop:
LOOP: slt $t2, $0, $t1
beq $t2, $0, DONE
subi $t1, $t1, 1
addi $s2, $s2, 2
j LOOP
DONE:
4a) Assume that the register $t1 is initialized to the value 10. What is the value in register $s2 assuming $s2 is initially zero?
4b) For each of the loops above, write the equivalent C code routine. Assume that the registers $s1, $s2, $t1, and $t2 are integers A, B, i, and temp, respectively.
4c) For the loops written in MIPS assembly above, assume that the register $t1 is initialized to the value N. How many MIPS instructions are executed?
In: Computer Science
Lab #3 – Recursion on Strings Lab Objectives • Be able to write a recursive Java method for Java strings • Be able to make use of exploit natural conversion between strings and integers • Be able to write a driver to call the methods developed for testing Deliverables Submit the report in Word or PDF format with the results of every task listed below. They should show screen capture of your results. The problem String as a sequence of characters for developing recursive method Given a Java string object, we observe that it is a sequence (or ordered list) of characters. Our goal is to employ a very common technique in computer science—namely, dividing the list into its head (it’s first element) and its tail (the remaining list with the first element removed). We can then recurse on the tail, which happens to be smaller. We use this technique for reversing a string, or for checking whether it is a palindrome (reads the same if you read it from left or right). Task #1 Develop a left recursive method to reverse a string Develop a method with the prototype public static String reverseRecursiveLeft (String input) based on selecting the leftmost character as the head and the remaining part of the string as its tail. Here is the recursive design. 1. Base case: The problem is trivial when the string length is 0 or 1. 2. Decomposition: For strings of length > 1: • Extract its head (character) and the tail. You are expected to know the string methods needed to achieve this. • Make a recursive call to obtain the tail reversed. 3. Composition: Append (concatenate) the head to obtain the original string reversed. Task #2 Develop a right recursive method to reverse a string Develop a method with the prototype public static String reverseRecursiveRight (String input) based on selecting the rightmost character as the head and the remaining part of the string on its left as the tail. The only difference in the recursive design is that the reversed tail needs to be appended after the head character. Page 2 of 2 Task #3 Develop a middle recursive method to reverse a string Develop a method with the prototype public static String reverseRecursiveMiddle (String input) This time, instead of extracting one element (character) from left or right, extract two characters simultaneously from both left and right. design. This leads to a drop of 2 in size of the reduced problem. Be careful to take this into account when you design the base case. Should the base case be any different? Consider odd and even size strings Task #4 Develop a method to reverse an integer (as written in decimal form) Develop a method with the prototype public static int reverse (int input) using any of the previous three methods you developed for reversing a string. Note that, • For a negative integer, the result should also be negative with the digits reversed, i.e., your method should return -321 when presented with input -123. • You can make use of the toString() method available to any object. However, wrapper classes are needed for this, while operating on a primitive variable such as int. • The reconversion is easily achieved by the parse family of methods also available in the wrapper class. Task #5 Develop a middle recursive method to check whether a string is palindrome. Develop a method with the prototype public static boolean isPalindrome (String input) to check if a string is a palindrome. Determine which of the three types of recursion (left, right, or middle) maps directly to this problem. Also, overload the isPalindrome() for integer inputs as public static boolean isPalindrome (int input) using the same technique of integer-string inter-conversion. The same rule of reversing applies to negative numbers, i.e., only digits are considered for deciding whether the number is a palindrome. Write a driver to test your program and include screen captures in your report.
In: Computer Science
Looking for code to this stepping stone lab 6
Prompt:
In Stepping Stone Lab Five, you created a Recipe Class. Now, in
Stepping Stone Lab Six, you will focus your skills on developing
your own driver class including custom methods to access elements
of the Ingredient and Recipe classes.
Specifically, you will need to create the following:
The instance variables for the class (listOfRecipes)
Accessors and mutators for the instance variable
Constructors
Three custom methods: printAllRecipeDetails(),
printAllRecipeNames, and addNewRecipe
Guidelines for Submission: This assignment should be submitted as a
Java file.
Extending This Lab for Your Final Project For your final project
submission, you should add a menu item and a method to access the
custom method you developed for the Recipe class based on the
Steppcing Stone Lab Five.
Code given:
package SteppingStones;
import java.util.ArrayList;
public class SteppingStone6_RecipeBox {
/**
* Declare instance variables:
* a private ArrayList of the type
SteppingStone5_Recipe named listOfRecipes
*
*/
/**
* Add accessor and mutator for listOfRecipes
*
*/
/**
* Add constructors for the
SteppingStone6_RecipeBox()
*
*/
/**
* Add the following custom methods:
*
* //printAllRecipeDetails(SteppingStone5_Recipe
selectedRecipe)
* This method should
accept a recipe from the listOfRecipes ArrayList
* recipeName and use
the SteppingStone5_Recipe.printRecipe() method
* to print the
recipe
*
* //printAllRecipeNames() <-- This method should
print just the recipe
* names of each of the
recipes in the listOfRecipes ArrayList
*
* //addRecipe(SteppingStone5_Recipe tmpRecipe) <--
This method should use
* the
SteppingStone5_Recipe.addRecipe() method to add a new
*
SteppingStone5_Recipe to the listOfRecipes
*
*/
/**
* A variation of following menu method should be used
as the actual main
* once you are ready to
submit your final application. For this
* submission and for
using it to do stand-alone tests, replace the
* public void menu()
with the standard
*
public static main(String[] args)
* method
*
*/
public void menu() {
// Create a Recipe Box
//SteppingStone6_RecipeBox
myRecipeBox = new SteppingStone6_RecipeBox(); //Uncomment for main
method
Scanner menuScnr = new Scanner(System.in);
/**
* Print a menu for the user to
select one of the three options:
*
*/
System.out.println("Menu\n" + "1.
Add Recipe\n" + "2. Print All Recipe Details\n" + "3. Print All
Recipe Names\n" + "\nPlease select a menu item:");
while (menuScnr.hasNextInt() || menuScnr.hasNextLine()) {
System.out.println("Menu\n" + "1. Add Recipe\n" + "2. Print All
Recipe Details\n" + "3. Print All Recipe Names\n" + "\nPlease
select a menu item:");
int input = menuScnr.nextInt();
/**
* The code below
has two variations:
*
1. Code used with the SteppingStone6_RecipeBox_tester.
* 2.
Code used with the public static main() method
*
* One of the
sections should be commented out depending on the use.
*/
/**
* This could
should remain uncommented when using the
*
SteppingStone6_RecipeBox_tester.
*
* Comment out
this section when using the
*
public static main() method
*/
if (input == 1)
{
newRecipe();
} else if (input == 2) {
System.out.println("Which recipe?\n");
String selectedRecipeName = menuScnr.next();
printAllRecipeDetails(selectedRecipeName);
} else if (input == 3) {
for (int j = 0; j < listOfRecipes.size();
j++) {
System.out.println((j + 1) + ": " +
listOfRecipes.get(j).getRecipeName());
}
} else {
System.out.println("\nMenu\n" + "1. Add Recipe\n" + "2. Print
Recipe\n" + "3. Adjust Recipe Servings\n" + "\nPlease select a menu
item:");
}
/**
* This could
should be uncommented when using the
*
public static main() method
*
* Comment out
this section when using the
*
SteppingStone6_RecipeBox_tester.
*
if (input == 1)
{
myRecipeBox.newRecipe();
} else if (input == 2) {
System.out.println("Which recipe?\n");
String selectedRecipeName = menuScnr.next();
myRecipesBox.printAllRecipeDetails(selectedRecipeName);
} else if (input == 3) {
for (int j = 0; j <
myRecipesBox.listOfRecipes.size(); j++) {
System.out.println((j + 1) + ": " +
myRecipesBox.listOfRecipes.get(j).getRecipeName());
}
} else {
System.out.println("\nMenu\n" + "1. Add Recipe\n" + "2. Print
Recipe\n" + "3. Adjust Recipe Servings\n" + "\nPlease select a menu
item:");
}
*
*/
System.out.println("Menu\n" + "1. Add Recipe\n" + "2. Print All
Recipe Details\n" + "3. Print All Recipe Names\n" + "\nPlease
select a menu item:");
}
}
}
/**
*
* Final Project Details:
*
* For your final project submission, you should add a menu item and
a method
* to access the custom method you
developed for the Recipe class
* based on the Stepping Stone 5
Lab.
*
*/
In: Computer Science