In Java, design and implement a class called Cat. Each Cat class will contain three private variables - an integer representing its speed, a double representing its meowing loudness, and a String representing its name. Using the Random class, the constructor should set the speed to a random integer from 0 to 9, the meowing loudness to a random double, and the name to anything you want; the constructor should take no parameters. Write “get” and “set” methods for each variable, and one that prints all the variables. Finally, write a main method to test the methods in the class. The three variables must be private.
Then design and implement a class called CatOwner. Each CatOwner will have three private variables: a String representing the owner name, an integer representing how much cat food is left, and a cat; each cat should be an instance of the Cat class. The constructor can name the CatOwner anything you want, and the supply of food should be a random number greater than or equal to 10 and less than 50. Each cat’s name should be set to “Tinkles.” The constructor for CatOwner should take no parameters. Write “get” and “set” methods for the owner’s name, the food supply, and all the properties of the cat; also write a feedCat method that decreases the food supply by 1 and prints that the cat was fed. Next, write a method to print all class variables. Finally, write a main method to test your methods.
Design a driver class which instantiates two CatOwner objects. Next, perform the following five steps:
1. Change the name of the first cat owner to “John Doe” and his
dog’s name to “Whiskers.” Change the name of the second cat owner
to “George Washington.”
2. Increase the meowing loudness of the first cat owner’s cat by
.1, and set the speed of the second cat owner’s cat to 5.
3. Double the food supply of the first cat owner, and set the food
supply of the second to 25.
4. Have the first cat owner feed his cat three times, and have the
second cat owner feed his cat twice.
5. Print out all the information for both cat owners.
In: Computer Science
// staff should be coming in to
// campus, or staying at home. Only part of the code is here.
// It bases the decision based on a points system by asking
the
// user a set of questions and keeping track of how many
times
// it gets a yes response back.
//
// The code implements policy by assigning a weight to each of
the
// categories of symptoms/risk factors
// 1) Mild Symptoms (1pt each)
// 2) Severe Symptoms (2pt each)
// 3) Recent exposure (3pt each)
// 4) Risk factors (3pt each)
//
// This file implements only the checks FOR ( 1
MILD) symptoms.
//
// There are 5 errors in this code.
//
// ~-~-~- ~-~-~-~-~ ~-~-~-~-~ ~-~-~-~-~ ~-~-~-~-~ ~-~-~-~-~
~-~-~-~-~ ~-~-~-~-~|
import java.util.Scanner;
public class Fragment1 {
public static final int MILD_SYMPTOMS = 1;
// This method gets the next line of input from the
scanner and
// Checks to see if it is "yes" (in either upper or
lower case)
// If it is, it returns the number provided as the
second argument
// else, it returns 0.
public static int checkAndAdd(Scanner input, int
score){
String answer = input.nextLine();
if (answer.equalsIgnoreCase("yes")){
return 0;
} else {
return score;
}
}
// This method asks the user about a list of symptoms
and uses
// the checkAndAdd method to check the answers.
// Tt sums up a score based on MILD_SYMPTOMS for each
yes answer
// and returns the total.
public static int checkMildSymptoms(String name,
Scanner input) {
int score = 0;
System.out.println(name+ ", do you have chills? (yes/no)");
score--;
System.out.println(name+ ", do you have diarrhea? (yes/no)");
score += checkAndAdd(input, MILD_SYMPTOMS);
System.out.println(name+ ", do you have sore throat?
(yes/no)");
score += checkAndAdd(input, MILD_SYMPTOMS)
System.out.println{name+ ", do you have body aches?
(yes/no)");
score += checkAndAdd(input, MILD_SYMPTOMS);
System.out.println(name+ ", do you have headache? (yes/no)");
score += check&Add(input, MILD_SYMPTOMS);
return score;
}
public static void main(String[] args) {
int totalScore = 0; // Tabulates the likelihood of infection
int totalRisk = 0; // Tabulates the high risk categories
String name=""; // Stores the name so we can be friendly
// Setup the scanner so we can prompt the user for answers
Scanner input = new Scanner(System.in);
System.out.println("Your total score is "+
checkMildSymptoms(name,input)
+ " points");
}
}
In: Computer Science
*I JUST WANT A GENERAL WALKTHROUGH OF HOW TO DO THIS. PSEUDOCODE IS FINE. THANK-YOU. THIS IS IN C THE PROGRAMMING LANGUAGE.*
The program will require the following structure:
struct _data {
char *name;
long number;
};
The program will require command line arguments:
int main(int argv, char **argc) {
Where argv is the number of arguments and argc is an array
holding the arguments (each is a string). Your program must catch
any case where no command line arguement was provided and print
a warning message (see below).
You MUST include/use the following functions, defined as follows:
int SCAN(FILE *(*stream)) - this function will open the file/stream
and return an integer indicating how many lines there are. Note that
I need to pass stream, which is a pointer, by reference. So I am
passing this as a pointer to a pointer.
struct _data *LOAD(FILE *stream, int size) - this function will
rewind file, create the dynamic array (of size), and read in the
data, populating the _data struct dynamic array. Note that stream
is passed by value this time. The function then returns the populated
array of struct.
void SEARCH(struct _data *BlackBox, char *name, int size) - this function
will get the dynamic array of struct passed to it, the name we are looking
for, and the size of the array. This function will then search the dynamic
array for the name. See below for examples.
void FREE(struct _data *BlackBox, int size) - this function will free up
all of the dynamic memory we allocated. Take note of the number of times
malloc/calloc were called, as you need to free that same number.
Finally, the data file will be called hw5.data and will be formatted as:
ron 7774013
jon 7774014
tom 7774015
won 7774016
HINTS:
------
Functions that will make things much easier:
getline()
feof()
strtok()
atoi()
SAMPLE RUNS:
------------
Case 1 - No command line argument provided.
[yourname@chef junk]$ ./CS230-5
*******************************************
* You must include a name to search for. *
*******************************************
Case 2 - Provided name is NOT in the list.
[yourname@chef junk]$ ./CS230-5 joe
*******************************************
The name was NOT found.
*******************************************
Case 3 - Provided name is in the list.
*******************************************
The name was found at the 2 entry.
*******************************************
In: Computer Science
Suppose a dairy farmer obtained a $100,000 loan to buy creamery equipment on June 1, 2016. There was no down payment, and the loan is payable over 5 years in equal payments of $20,000 due on June 1st each year (first payment June 1, 2017), with the remaining balance due at the end of the loan term. The annual interest rate is 5%.
Businesses often need to compute the amount of accrued interest payable as of the date of a financial statement, such as a balance sheet. Approximately how much accrued interest would this loan contribute to the dairy farmer’s year-end balance sheet for 2016?
In: Finance
Corporate Law
The company is prohibited from purchasing, dealing in or lending money on its own shares. Therefore, a company is prohibited from buying back its shares, which tantamount to giving priority to the member who is selling his shares, over the company's creditors and other members. This transaction will also result in the reduction of the company's capital.
Based on the statement above critically discuss exceptions to
the prohibition of share buy-back as provided under the Companies
Act 2016. Support your answer with relevant statutory provisions of
the Companies Act 2016 and decided cases.
Thanks advanced.
In: Operations Management
Why do corporations issue convertible securities?
What are the advantages of using restricted stock to compensate employees?
What are the disadvantages of using restricted stock to compensate employees?
What are some reasons that employees might prefer this type of compensation?
Skim through the major tenets of the PwC Stock-based compensation. In March 2016, the FASB issued Accounting Standards Update (ASU) 2016-09, Compensation—Stock Compensation (Topic 718): Improvements to Employee Share-Based Payment Accounting, which amends ASC 718. What are a few of the improvements to employee share-based payment accounting discussed in the report?
In: Accounting
Table 3: Annual Returns
|
Year |
Returns |
|
2000 |
-9.0% |
|
2001 |
-11.9% |
|
2002 |
-22.0% |
|
2003 |
28.4% |
|
2004 |
10.7% |
|
2005 |
4.8% |
|
2006 |
15.6% |
|
2007 |
5.5% |
|
2008 |
-36.6% |
|
2009 |
25.9% |
|
2010 |
14.8% |
|
2011 |
2.1% |
|
2012 |
15.9% |
|
2013 |
32.2% |
|
2014 |
13.5% |
|
2015 |
1.4% |
|
2016 |
11.7% |
Calculate:
In: Finance
. The attached file contains the six variables. I have already attempted this answer and got it wrong. Please ignore the checkmarks.
Question
Using the information below select all of the variables that are
dichotomous (i.e., two categories).
QN88
QN33
_SMOKER3
_SLEPTIM1
QN44
_RFBING5
Behavioral Risk Factor Surveillance System (BRFSS 2016)
Calculated Variables
https://www.cdc.gov/brfss/annual_data/2016/pdf/2016_calculated_variables_version4.pdf
Youth Risk Behavior Surveillance System (YRBSS 2015) YRBS Data
User's Guide
https://www.cdc.gov/healthyyouth/data/yrbs/pdf/2015/2015_yrbs-data-users_guide_smy_combined.pdf
In: Statistics and Probability
The shareholders’ equity of MLS Enterprises includes $100
million of no par common stock and $200 million of 6% cumulative
preferred stock. The board of directors of MLS declared cash
dividends of $31 million in 2018 after paying $7 million cash
dividends in both 2017 and 2016.
What is the amount of dividends common shareholders will receive in
2018?
| Par Value Preferred Stock | Dividend Rate (%) | Annual Preferred Dividend | ||
| Annual Preferred Dividend: | ||||
| Total Cash Dividend Paid | Paid to Preferred | Paid to Common | Dividends in Arrears at year-end | |
| 2016 | ||||
| 2017 | ||||
| 2018 | ||||
| Total |
In: Accounting
Please show your work.
Economy of Penny-Blossom calculates price index of hair product. People in Penny-Blossom buy hair dryers, hair brushes, and hair accessories. In 2015, they bought 1 hair dryers for $30, 2 hair brushes for $10 each, and 5 hair accessories for $4 each. In 2016, they bought 1 hair dryer for $35, 3 hair brushes for $12 each, and 6 hair accessories for $5 each. Year 2015 is a base year. What is the CPI for 2016?
Question options:
|
|||
|
|||
|
|||
|
In: Economics