Questions
In Java, design and implement a class called Cat. Each Cat class will contain three private...

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...

// 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...

*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

Design a Ship class that has the following members: • A member variable for the name...

Design a Ship class that has the following members:

• A member variable for the name of the ship (a string)
• A member variable for the year that the ship was built (a string)
• A constructor and appropriate accessors and mutators
• A virtual print function that displays the ship’s name and the year it was built.

Design a CruiseShip class that is derived from the Ship class. The CruiseShip class
should have the following members:

• A member variable for the maximum number of passengers (an int )
• A constructor and appropriate accessors and mutators
• A print function that overrides the print function in the base class. The CruiseShip class’s print function should display only the ship’s name and the maximum number of passengers.

Design a CargoShip class that is derived from the Ship class. The CargoShip class
should have the following members:

• A member variable for the cargo capacity in tonnage (an int ).
• A constructor and appropriate accessors and mutators.
• A print function that overrides the print function in the base class. The CargoShip class’s print function should display only the ship’s name and the ship’s cargo capacity.

After you have created these classes, create a driver program that defines an array pointers to your abstract base class Ship. It should present a menu to allow the user to enter a Cruise Ship or a Cargo Ship. When the user selects cruise ship, it should prompt them for the name, year built, and the number of passengers. When the user selects cargo ship, it should prompt them ffor the name, year built, and the maxium cargo load (in tons). Each selection should create an object that can be stored into your array of pointers. When the program exits, it should display the history of the session which includes each of the objects the user created which will be a combination of cruise ships and cargo ships. An example output is shown here:

Menu

1. Cruise Ship
2. Cargo Ship
3. Quit
Please make your selection: 2

Please enter the name of the ship: Big Bertha
Please enter the year the ship was built: 1975
Please enter the capacity (tons): 50000

Menu

1. Cruise Ship
2. Cargo Ship
3. Quit
Please make your selection: 1

Please enter the name of the ship: Disney Magic
Please enter the year the ship was built: 1998
Please enter the capacity (passengers): 2400

Menu

1. Cruise Ship
2. Cargo Ship
3. Quit
Please make your selection: 3

The history of your session is

Selected Cargo Ship

Name: Big Bertha
Year: 1975
Capacity (tons): 50000

Selected Cruise Ship

Name: Disney Magic
Year: 1998
Capacity (passengers): 2400

In: Computer Science

please , im sorting by name, address, dependent and hours. i got a lot of errors...

please , im sorting by name, address, dependent and hours. i got a lot of errors i need help please. Thanks

package application;

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.*;

class Emprec {

String name;

String address;

double hours;

double rate;

int dependents;

char gender;

boolean degree;

// This is the classes's constructor !!!!

Emprec(String name, String address, String hours,String dependents) {

try {

this.name = name;

this.address = address;

this.hours = Double.valueOf(hours).doubleValue();

this.dependents = Integer.parseInt(dependents);

} catch (NumberFormatException errmsg) {

System.out.println("Invalid format" + errmsg);

this.name = "";

this.hours = 0.0;

}// catch

}// Emprec constructor !!!!

double calc_fed_tax(double hours, double rate) {

double yearly_income;

yearly_income = hours * rate * 52;

if (yearly_income < 30000.00)

return (hours * rate * .28);

else if (yearly_income < 50000.00)

return (hours * rate * .32);

else

return (hours * rate * .38);

}// calc_fed_tax

double calc_state_tax(double hours, double rate) {

double state_tax;

state_tax = hours * rate * .0561;

return (state_tax);

}// calc_state_tax

public void setName(String name) {

this.name = name;

}

public String getName() {

return name;

}

public String getAddress() {

return address;

}

public double getHours() {

return hours;

}

public int getDependents() {

return dependents;

}

  

public double getRate(){

return rate;

}

  

public char getGender(){

return gender;

}

public String toString() {

return ("\n Name: " + name +

"\n Address: " + address +

"\n Hours: " + hours+

"\n Dependents " + dependents);

}// toString

}// Emprec

public abstract class CompDemo3Sorts_Improved {

public abstract void main(String args[]);{

Scanner sc=new Scanner(System.in);

System.out.println("Enter the fields to sort by");

String s=sc.next();

if(s=="name"){

String str[]=name.split(" ");

List<String> slist= new ArrayList<String>();

str=Arrays.asList(str);

List<String> sortedList=slist.stream().sorted().collect().(collector().toList());

sortedList.forEach(System.out.println());

}

if(s=="address"){

String str1[]=address.split(" ");

List<String> slist1= new ArrayList<String>();

str1=Arrays.asList(str1);

List<String> sortedList=slist1.stream().sorted().collect().(collector().toList());

sortedList.forEach(System.out.println());

}

if(s=="hours"){

String str2[]=hours.split(" ");

List<String> slist2= new ArrayList<String>();

str2=Arrays.asList(str2);

List<String> sortedList=slist2.stream().sorted().collect().(collector().toList());

sortedList.forEach(System.out.println());

}

if(s=="dependent"){

String str[]3=dependent.split(" ");

List<String> slist3= new ArrayList<String>();

str3=Arrays.asList(str3);

List<String> sortedList=slist3.stream().sorted().collect().(collector().toList());

sortedList.forEach(System.out.println());

}

}}

In: Computer Science

Challenge: Dog Description: Create a Dog class that contains specified properties and methods. Create an instance...

Challenge: Dog

Description: Create a Dog class that contains specified properties and methods. Create an instance of Dog and use its methods.

Purpose: This application provides experience with creating classes and instances of objects in C#.

Requirements:

Project Name: Dog
Target Platform: Console
Programming Language: C#

Documentation:

  • Types and variables (Links to an external site.) (Microsoft)
  • Classes and objects (Links to an external site.) (Microsoft)
  • Enums (Links to an external site.) (Microsoft)

Create a class called Dog.

Dog is to have the following public properties:

  • name (of type string)
  • owner (of type string)
  • age (of type int)
  • gender (of type Gender)

Gender is a enum type you need to create that contains Male and Female.

Create a constructor (Links to an external site.) in the class to initialize all of the properties when creating an instance.

Create a method (function in the class) called Bark that takes one parameter that is the number of times to bark and prints “Woof!” that many times to the Console.

Create a method called GetTag that takes no parameters and returns a string. The method returns “If lost, call [owner]. [‘Her’|‘His’] name is [name] and [‘she’|‘he’] is [age] [‘year’|‘years’] old.”

[owner] means replace with the name of the owner.

[‘Her’|‘His’] means choose to display “Her” or “His” based on the gender of the Dog.

[name] means replace with the name of the Dog.

[‘she’|‘he’] means choose to display “she” or “he” based on the gender of the Dog.

[‘year’|‘years’] means to choose to display “year” or “years” depending on the age of the Dog. If age is 1, use “year”. If any other age, use “years”.

In the Main function of the application, test that instances of Dog can be created and that the methods work. In the following, “Orion” is the name of the Dog instance, “Shawn” is the owner, 1 is the age, and Gender.Male is the gender.

Dog puppy = Dog("Orion", "Shawn", 1, Gender.Male);  // create object instance
puppy.Bark(3); // output: Woof!Woof!Woof!
Console.WriteLine(puppy.GetTag()); // output: If lost, call Shawn. His name is Orion and he is 1 year old.

Dog myDog = Dog("Lileu", "Dale", 4, Gender.Female);  // create object instance
myDog.Bark(1); // output: Woof!
Console.WriteLine(myDog.GetTag()); // output: If lost, call Dale. Her name is Lileu and she is 4 years old.

Submission

You are to submit a zip file of the project directory for the application you create. The entire project is to be submitted. Find the project folder that holds the Visual Studio project and zip it.

When you finish can you send pictures of the code with spacing

In: Computer Science

At the beginning of 2016, IASB issued a new standard (IFRS 16) on leasing accounting. Explain...

At the beginning of 2016, IASB issued a new standard (IFRS 16) on leasing accounting. Explain the reasons behind this decision and the impact on companies’ financial statements.

In: Accounting

In what ways was the Republican party fracturing before the 2016 election? Essentially, how do we...

In what ways was the Republican party fracturing before the 2016 election? Essentially, how do we know it was a highly factionalized party?

*This is all the information*

In: Economics

How much was Target Corporation’s long-term debt at January 30, 2016? can you please explain in...

  1. How much was Target Corporation’s long-term debt at January 30, 2016? can you please explain in detail how this is calculated? thanks

In: Finance

in dollars outstanding in 2016, the largest money market security was Multiple Choice commercial paper. banker's...

in dollars outstanding in 2016, the largest money market security was Multiple Choice commercial paper. banker's acceptances. T-bills. Fed funds and repos.

In: Finance