Accounting

In each of the following independent cases in which the partnership owns no hot assets, indicate:

• Whether the partner recognizes gain or loss.

 • Whether the partnership recognizes gain or loss.

• The partner’s adjusted basis for the property distributed.

• The partner’s outside basis in the partnership after the distribution.

a. Kim receives $20,000 of cash in partial liquidation of her interest in the partnership. Kim’s outside basis for her partnership interest immediately before the distribution is $3,000.

b. Kourtni receives $40,000 of cash and land with an inside basis to the partnership of $30,000 (value of $50,000) in partial liquidation of her interest. Kourtni’s outside basis for her partnership interest immediately before the distribution is $80,000.

c. Assume the same facts as in (b), except that Kourtni’s outside basis for her partnership interest immediately before the distribution is $60,000.

d. Klois receives $50,000 of cash and inventory with a basis of $30,000 and a fair market value of $50,000 in partial liquidation of her partnership interest. Her basis was $90,000 before the distribution. All partners received proportionate distributions.

Computer Science

Mini Case

Reinventravel.com Comes under Fire

As you watch the sun setting over the San Francisco skyline from your hotel room window, you can’t avoid feeling that you really dropped the ball this time. You can still hear Clive Sturling, your chief information officer (CIO), as he tells you, “Don’t worry about security. That’s techie stuff; I’ll take care of it. Just grow the business. That’s what you are good at.” You had not asked
about security again after that conversation, perfectly happy to leave the “techie stuff” to him, and that was before you launched the company over two years ago!
Well, it was him on the phone a minute ago, ruining what had been a perfectly good day. In a daze, you replay the conversation in your mind: “We have been attacked,” Clive had said. “It was a distributed denial of service attack, not much we could do with our current security infrastructure. The site was unavailable for about 70 minutes; it wasn’t defaced or otherwise ruined, just down. I don’t think many people noticed. The attack ended about an hour ago. I didn’t want to call you before checking if they had compromised any files. It doesn’t look like it.”
Not much we could do? Isn’t he the one who said not to worry about security? The site was down for “only 70 minutes.” Does he know that in that amount of time Reinventravel.com typically processed 19,000 transactions? Granted, evenings were a bit slower, but there must have been at least 4,500 customers who noted the outage. Your emotions kept mixing at a dizzying pace. You were angry at Clive; you trusted him and he let you down. However, you felt sympathetic to his position as well. You had been the one who told him to “run IT on a shoestring,” to help you speed the path to profitability as much as possible.
Oddly enough, as you begin to recover from the shock of the news, your college days flash into your mind, bringing a smile to your face. You had started in this field only three and a half years before, when you learned in one of your classes about the opportunity to revolutionize how people seek and purchase travel products. That day in your information systems class seemed like decades ago; now you were the chief executive officer (CEO) of a growing company with 52 employees, over 70,000 active customers and members, and revenues approaching $8 million. Clive had built the search engine in just eight months alone! He was a wizard with that kind of stuff. Half the time, you had no idea what he was doing, but as for the user interface, you certainly appreciated and understood that part of his work; everyone did! It was so far superior to anything that had been seen before . . . it was that fabulous demo that got you your first round of venture capital financing.
Financing . . . that word snapped you back to reality! You had to get ready for dinner. The meeting with your venture capital (VC) was in less than an hour, and you had yet to take a shower. With the first round of financing beginning to run out and minimal profits, a second round was a must. You had hoped to spend the evening discussing your plan for growing the customer
base and beginning to monetize your membership, seeking their guidance and help with regard to the three potential partners you were evaluating. “Well, that ain’t going to happen,” you mumbled.
What should you do? Should you tell your VC about the denial-of-service attack? It may not be your choice; these guys liked to do their homework, and the odds were good that they were poking around the site when the outage happened. No time to call your legal counsel; you had to go it alone on this one.
Clive had been very unclear about whether an intrusion had occurred along with the denial-of-service attack. At this point you had little faith with regard to his staff’s ability to find out; it seems that security and monitoring had not been ranking very high on their priority list! Reinventravel.com stored quite a bit of personal information about customers, including identifying information and credit card data. Should you communicate to the customers that an attack had occurred? Should you issue a press release? There was no evidence that security had been compromised and even less that personal data had been stolen. A denial-of-service attack only made a website unavailable for some time, did it not? “No way, Clive and his staff would know if data had been stolen,” you told yourself.
This was increasingly looking like a situation you were ill prepared to address. But as your father always said, “You wanted the bicycle? Now you have to pedal.” As you began to feel the adrenaline pumping again, you exclaimed, “Here we go!” and jumped up from your chair. You had 55 minutes to develop your plan before dinner.

1. Do you agree with the assessment that you had dropped the ball? Or are you being unduly harsh on yourself?

2. Who do you think should be making security calls at Reinventravel.com? Shouldn’t this be the CIO’s job?

3. What should you do tonight? Should you approach the topic at dinner or wait and see if anyone else raises the issue?

4. What should you do in the next few days? Should you issue a press release? Should you contact your customers directly? Should you focus on overhauling your security safeguards to prevent future similar problems and forget today’s incident?

just simply do the read and then move on
# file_input.read(3)
size = file_input.read(1)
print(“”size: “”

Interface the Cake program to files

Now, let’s say we want to make the cake program more versatile that it can process the cake orders as a “batch” – archive from computer storage and generate the document for ingredients required to fill the cake orders.

Part 1 – Write the ingredients list to a file (10 points)

Option 1 – Your Lab 5 work with no problem:

Modify the program you developed for Lab 5 to make it output the data in the same format to a text file cake_ingredients_list.txt

Option 2 – Your Lab 5 still has functionality problem:

Modify the template given here (To Be Posted) to get the sentinel while loop working first, then make it to output the data in the same format to a text file cake_ingredients_list.txt

Note:Writing to a file is easier to code, so let’s do that first.

Hints:After the file has been opened, call the .write() function to write one line at a time to the file, in almost the exact fashion as calling print(). The difference is that the .write() function won’t place a new line feed to the end automatically like print(), soan explicit “n” has to be added(concatenated) to the end of the current line of data to be output.And, please read the code example from the bottom of Module 7.2 : write_a_single_line_to_file.py

Part 2 – Read the cake orders list from a text file (10 points)

Modify the program further to make it read a text file to input the cake orders. Or, if you want to leave Part 1 alone and/or not confident about your Part 1, then just do Part 2 in a different program. And, if you didn’t integrate the two, you have to submit TWO .py files – one for Part 1 and Part 2.

The data file that contains the orders has this format, for each line:

[1 character: cake type] [ 3 white spaces] [ 1 character: cake size ]

e.g.

2 L

means: Red Velvet; Large

You are welcome to use any scheme you see fit to read and process the raw data from the file. Or, follow the suggestion below.

Hint: Use .read(n) to read n characters at a time. Specifically, for each line, cake order:

1) read 1 character to get the cake type(1, 2 or 3);
2) read 3 characters(white spaces) and then discard them, in order to move the read queue up;
3) read 1 character to get the cake size(L or R);
4) read 1 character(‘n’), and discard it; Then repeat for the next line, and so forth – all the way until no more character left, meaning when the last read gives(no character, two single quotes), which would be the sentinel like this:

while char != ”:

Code example download:

file_input = open(“data.txt”)
cake_char = file_input.read(1)
print(“cake_code: “, cake_char)
cake_num = eval(cake_char)
print(“ck_num**2 = “, cake_num**2)
spaces = file_input.read(3)
print(“delimiter – spaces: “%s”””” % spaces)
# or

isPalindrome(“”a””));
System.out.printf(“”isPalindrome(“”Aibohphobia””) should be true -> %bn””

Objectives

  • Increase familiarity with recursive logic by working through several recursive problems.

  • Taking into consideration a few corner cases through analyzing the test cases.

  • Using a regex expression that will remove punctuation.

Getting Started

This lab includes the following .java file:

L4/
+– Recursion.java
+– Main.java*
*Main.java is a read-only file used for testing. It is not included in the starter jar.
Here is the starter jar if you would like to code in a different environment: L4.jar.

Please complete ALLfunctions. Make sure to read the description for each function carefully.

Do not include any for or while loops in your methods. These can all be completed in a purely recursive style, so do it recursively!

In the spirit of incremental development, implement each method one at a time, look at the test cases and take into consideration what is being tested, then uncomment the corresponding test code and see if it works. If not, try to determine what went wrong and try again.

Lab Assignment

In this lab, you will complete the following methods:
– fib
– mult
– expt
– isPalindrome
– longestWordLength
– dedupeChars

1. The Fibonacci Method

TO DO:
1. Write this method so that it returns the Fibonacci number for any input integer n.
The Fibonacci sequence begins with 0 and then 1 follows. All subsequent values are the sum of the previous two, for example: 0, 1, 1, 2, 3, 5, 8, 13. Complete the fib() method, which takes in an index, n, and returns the nth value in the sequence. Every number after the first two is the sum of the two preceding ones.
For each index 0, 1, 2, 3, 4, 5, 6…
the output is: 0, 1, 1, 2, 3, 5, 8…

When you run this method, your output should look like this:

Testing the fibonacci method
fib(0) should be 0 -> 0
fib(1) should be 1 -> 1
fib(2) should be 1 -> 1
fib(5) should be 5 -> 5
fib(10) should be 55 -> 55
fib(13) should be 233 -> 233

Thank you for your time!

Main.Java

public class Main extends Recursion{

public static void main(String [] args){
//This is essentially the same as the main in Recursion.java
//This tests each method implemented and is a read-only file.

System.out.println(“Testing the fibonacci method”);
System.out.printf(“fib(0) should be 0 -> %dn”, fib(0));
System.out.printf(“fib(1) should be 1 -> %dn”, fib(1));
System.out.printf(“fib(2) should be 1 -> %dn”, fib(2));
System.out.printf(“fib(5) should be 5 -> %dn”, fib(5));
System.out.printf(“fib(10) should be 55 -> %dn”, fib(10));
System.out.printf(“fib(13) should be 233 -> %dn”, fib(13));
System.out.println();

Recursion.Java

import java.util.Scanner;

/**
* Recitation created by Gareth Halladay, 08/17.

* Content was gathered from two sources:
*

    *

  • http://www.cs.wustl.edu/~kjg/cse131/modules/recursion/lab.html
    *
  • http://codingbat.com/prob/p273235?parent=/home/bono@usc.edu/recursionLab
    *

*
*/
public class Recursion {

/**
* Every number after the first two is the sum of the two preceding ones.

* index: 0, 1, 2, 3, 4, 5, 6…

* output: 0, 1, 1, 2, 3, 5, 8…
* @param n which fibonacci number to compute.
* @return the fibonacci number.
*/
public static int fib(int n){
return 0;
}

/**
* Write a multiplication method recursively using repeated addition.

* Do not use the multiplication operator or a loop.
*
* @param j a positive or negative integer.
* @param k a positive or negative integer.
* @return the product of the k and j.
*/
public static int mult(int j, int k){
return 0;
}

/**
* Write a method that computes j^k.

* Do not use Math.pow() or a loop.

* @param j a non-negative number
* @param k a non-negative number
* @return j^k
*/
public static int expt(int j, int k){
return 0;
}

/**
* Check to see if a word is a palindrome. Should be case-independent.
* @param word a String without whitespace
* @return true if the word is a palindrome
*/
public static boolean isPalindrome(String word){
return false;
}

/**
* Returns length of the longest word in the given String using recursion (no loops).
* Hint: a Scanner may be helpful for finding word boundaries. After delimiting by space,
* use the following method on your String to remove punctuation {@code .replaceAll(“[^a-zA-Z]”, “”)}
* If you use a Scanner, you will need a helper method to do the recursion on the Scanner object.
*
* @param words A String containing one or more words.
* @return The length of the longest word in the String.
* @see Scanner#Scanner(String)
* @see Scanner#next()
* @see String#split(String)
* @see String#replaceAll(String, String)
* @see Math#max(int, int)
*/
public static int longestWordLength(String words){
return 0;
}

/**
* Remove consecutive duplicate characters from a String.

* Case should not matter, if two or more consecutive duplicate

* characters have different cases, then the first letter should be kept.
* @param word A word with possible consecutive duplicate characters.
* @return A word without any consecutive duplicate characters.
*/
public static String dedupeChars(String word){
return null;
}

public static void main(String [] args){
// Test your methods here!
// Uncomment each block as you are ready to test it.
//Note: in zyBooks the main in Main.java will run instead, and it is all of the below statements.

/*
System.out.println(“Testing the fibonacci method”);
System.out.printf(“fib(0) should be 0 -> %dn”, fib(0));
System.out.printf(“fib(1) should be 1 -> %dn”, fib(1));
System.out.printf(“fib(2) should be 1 -> %dn”, fib(2));
System.out.printf(“fib(5) should be 5 -> %dn”, fib(5));
System.out.printf(“fib(10) should be 55 -> %dn”, fib(10));
System.out.printf(“fib(13) should be 233 -> %dn”, fib(13));
System.out.println();

System.out.println(“Testing out the multiplication method”);
System.out.printf(“mult(8, 2) should be 16 -> %dn”, mult(8, 2));
System.out.printf(“mult(2, 8) should be 16 -> %dn”, mult(2, 8));
System.out.printf(“mult(4, -3) should be -12 -> %dn”, mult(4, -3));
System.out.printf(“mult(-3, 4) should be -12 -> %dn”, mult(-3, 4));
System.out.println();

System.out.println(“Testing out the exponent method”);
System.out.printf(“expt(2, 5) should be 32 -> %dn”, expt(2, 5));
System.out.printf(“expt(5, 2) should be 25 -> %dn”, expt(5, 2));
System.out.println();

System.out.println(“Testing out the palindrome method”);
System.out.printf(“isPalindrome(“a””) should be true -> %bn””

wordsChange);
}
else{
System.out.printf(“”Your new sentence is: %snn””

First, let’s make some changes to the existing code:
1. In the StringUtilities class add a modifier (or getter) method to retrieve the currently stored string
2. In the Lab class replace all invocations of the StringUtilities class with the Editor class
3. In the Lab class add in the new commands and their corresponding invocations
Now it’s time to modify the Editor class. This is where the bulk of the modifications are:
1. Implement the undo, redo, and reset functions
2. Implement the transformString methods so that they fill up the undo-redo-buffer while still
transforming the string.

import java.util.Scanner;

public class Lab {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
String original;
String command;
char charsChange;
String wordsChange;
char replaceThis;
String replaceThisWord;
char charsReplace;
String wordsReplace;
char withThis;
String withThisWord;
String transform;
int replaceHere;
int replaceWordHere;

System.out.printf(“nYou can perform the following operations:n” +
“Replace chars: replace all occurrences of a character another charactern”+
“Replace words: replace all occurrences of one word with another wordn”+
“Replace char: replace a specific occurrence of a charactern”+
“Replace word: replace a specific occurrence of a wordn”+
“Undo: Undo the last operationn” + “Redo: Redo the most recent undone operationn” +
“Reset: Reset to the intitial stringn”+
“Quitnn”);

System.out.printf(“Enter a string to be transformed: “);
original = scnr.nextLine();
StringUtilities m = new StringUtilities(original);
System.out.println();
do{
System.out.printf(“Enter your command: “);
command = scnr.nextLine();
//Exit command
if(command.equalsIgnoreCase(“Quit”)){
break;
}
else if(command.equalsIgnoreCase(“Replace words”)){
System.out.printf(“Enter the word to replace: “);
wordsChange = scnr.nextLine();
System.out.printf(“Enter the replacement word: “);
wordsReplace = scnr.nextLine();
if(m.transformString(wordsChange, wordsReplace) == false){
System.out.printf(“Error, “%s”” is not in the stringn””

Accounting

Uses of Unit Cost Information

SE11. Accounting Connection ▶ Doug, the owner of a miniature golf course with 36 holes of miniature golf, must make several business decisions soon. Write yes or no to indicate whether knowing the cost to provide one golf game (i.e., the service unit cost) can help Doug answer these questions:

a. Is the fee for playing a golf game high enough to cover the related cost?

b. How much profit will Miniature Golf make if it sells an average of 100 games per day for 50 weeks?

c. What costs can be reduced to make the fee more competitive?

Computer Science

 

Consider how to implement a mutex lock using an atomic hardware instruction. Assume that the following structure defining the mutex lock is available:

typedef struct {

int available;

} lock;

 

(available == 0) indicates that the lock is available, and a value of 1 indicates that the lock is unavailable. Using this struct, illustrate how the following functions can be implemented using the test and set()

and compare and swap() instructions:

• void acquire(lock *mutex)

• void release(lock *mutex)

Be sure to include any initialization that may be necessary

 

do {

while (true) {

flag[i] = want in;

j = turn;

while (j != i) {

if (flag[j] != idle) {

j = turn;

else

j = (j + 1) % n;

}

flag[i] = in cs;

j = 0;

while ( (j

j++;

if ( (j >= n) && (turn == i || flag[turn] == idle))

break;

}

/* critical section */

j = (turn + 1) % n;

while (flag[j] == idle)

j = (j + 1) % n;

turn = j;

flag[i] = idle;

/* remainder section */

} while (true);

Figure 5.22 The structure of process Pi in Eisenberg and McGuire’s algorithm.

 

“”grade””:”” << rand() % 51 + 50 <<“”}””;
int i = 0;
while ( file ) {
getline(file

Assume you just started at a company, and you are tasked with your first feature.

At this company, they use CMake, RapidJson and GoogleTest. CMake is a build tool that helps resolve dependencies and build the project. RapidJson is used to parse JSON files. GoogleTest is a testing framework. Your first task at this company is to take their existing student sorting library and change the sorting algorithm that is being used. The current sorting algorithm grabs the student data from the data/students.json file and uses the built in sorting library that comes with the system. Your boss wants you to change the sorting algorithm to one built in house for “performance and cost concerns”. You have already explained that the built in one should be good enough. But you don’t want to make too many waves so you decide to implement one that you learned in school.

Pick any sorting algorithm that you feel would work, but be prepared to defend it. Add to the documentation comment above your functions explaining your algorithm.

You will also need to write unit tests for your sorting algorithm, which can be found in the test/sort_test.cpp

sort.cpp

#include “sort.h”
#include “rapidjson/document.h”
#include “rapidjson/filereadstream.h”
#include

using namespace rapidjson;
using namespace std;

/**
* Implement this function
*/
void sort_students(list

list

Document document;
document.ParseStream(is);

const Value& arr = document;
list

for (SizeType i = 0; i < arr.Size(); i++) {
student s;
s.name = arr[i][“name”].GetString();
s.grade = arr[i][“grade”].GetInt();
students.push_back(s);
}

fclose(fp);

sort_students(students);

return students;
}

sort_test.cpp

#include “sort.h”
#include

using namespace std;

namespace {

/**
* Add a test here using GoogleTest library
*
* The test itself should verify that all of the students
* are sorted by grade in descending order.
*/
TEST(SortTest, SortShouldSortStudentsJsonByGrade) {
list

}

create_json.cpp

#include

using namespace std;

int main() {
ifstream file(“first-names.txt”);
ofstream out(“students.json”);

string line;
out << “[“;
if ( file.is_open() ) {
getline(file, line);
out << “{“name””:”””” << line << “”””

Computer Science