Assistance requested with understanding the outcome of code listed below.
Question Assistance requested with understanding the outcome of code listed below. focus on the following question in relation:Why would a programmer choose to define a method in an abstract class, such as the Animal constructor method or the getName() method in the linked code example, as opposed to defining a method as abstract, such as the makeSound() method in the example below/************************************************************************ Comments:* Notice that in the abstract Animal class shown here, one method is* concrete (the one that returns an animal’s name) because all animals can* be presumed to have a name. But one method, makeSound(), is declared as* abstract, because each concrete animal must define/override the makeSound() method* for itself–there is no generic sound that all animals make.**********************************************************************/package mytest;// Animal is an abstract class because “animal” is conceptual// for our purposes. We can’t declare an instance of the Animal class,// but we will be able to declare an instance of any concrete class// that derives from the Animal class.abstract class Animal {// All animals have a name, so store that info here in the superclass.// And make it private so that other programmers have to use the// getter method to access the name of an animal.private final String animalName;// One-argument constructor requires a name.public Animal(String aName) {animalName = aName;}// Return the name of the animal when requested to do so via this // getter method, getName().public String getName() {return animalName;}// Declare the makeSound() method abstract, as we have no way of knowing// what sound a generic animal would make (in other words, this// method MUST be defined differently for each type of animal,// so we will not define it here–we will just declare a placeholder// method in the animal superclass so that every class that derives from// this superclass will need to provide an override method// for makeSound()).public abstract String makeSound(); };// a concrete subclass named “Dog” that inherits from Animal.// Because Dog is a concrete class, we can instantiate it.class Dog extends Animal {// This constructor passes the name of the dog to// the Animal superclass to deal with.public Dog(String nameOfDog) {super(nameOfDog);}// This method is Dog-specific.@Overridepublic String makeSound() {return (“Woof”); }} // a concrete subclass named “Cat” that inherits from Animal.// Because Cat is a concrete class, we can instantiate it.class Cat extends Animal {// This constructor passes the name of the cat on to the Animal// superclass to deal with.public Cat(String nameOfCat) {super(nameOfCat);}// This method is Cat-specific.@Overridepublic String makeSound() {return (“Meow”);}}class Bird extends Animal {// This constructor passes the name of the bird on to the Animal// superclass to deal with.public Bird (String nameOfBird) {super(nameOfBird);}// This method is Bird-specific.@Overridepublic String makeSound() {return (“Squawk”);}}public class MyTest {public static void main(String[] args) {// an instance of the Dog class, passing it the name “Spot.” // The variable aDog that we create is of Animal.Animal aDog = new Dog(“Spot”);// an instance of the Cat class, passing it the name “Fluffy.” // The variable aCat that we create is of Animal.Animal aCat = new Cat(“Fluffy”);// an instance of (instantiate) the Bird class.Animal aBird = new Bird(“Tweety”);//Exercise two different methods of the aDog instance:// 1) getName() (which was defined in the abstract Animal class)// 2) makeSound() (which was defined in the concrete Dog class)System.out.println(“The dog named ” aDog.getName() ” will make this sound: ” aDog.makeSound());//Exercise two different methods of the aCat instance:// 1) getName() (which was defined in the abstract Animal class)// 2) makeSound() (which was defined in the concrete Cat class)System.out.println(“The cat named ” aCat.getName() ” will make this sound: ” aCat.makeSound());System.out.println(“The bird named ” aBird.getName() ” will make this sound: ” aBird.makeSound());}}
user-friendly flowchart for an algorithm
Build one user-friendly flowchart for an algorithm that reads an integral number x from the user, computes the areas of various shapes from the drawing bellow where AB, BD, FH, HJ, EG, AF, BH, DJ, LN, and CI are equal to x, BC, CD, HI, IJ, CM, MI, BL, DN, LM, and MN are half of x, and EF, GH, and JK are a quarter of x. and display one of the areas that the user selects. The algorithm should do all the following: I. Input a value from the user into variable x (only once) II. Compute all the following areas (only depending on x)1: 1. The area of the triangle AFE 2. The area of the square ABHF 3. The area of the rectangle BCIH 4. The area of the parallelogram ABGE 5. The area of the circle with center M
Hi,Just need to know how to plot a single lissajous
Question Hi,Just need to know how to plot a single lissajous curve with javascript, I am using p5.js. I need also mimic a oscilloscope with animation.
Can come help me with my code. It wont work
Question Can come help me with my code. It wont work no matter what I do idk what is wrong with it. It is c . my instructions are to: Do a program that simulates flipping a coin and rolling a dice.A user will input their choice of flipping a coin (C), rolling a dice (D), or exiting (E). if the user chooses a coin toss, the program will ask how many times the coin should be tossed, then will simulate tossing the coin that many times and print the result to the user. If the user chooses rolling a die, the program will ask how many sides the die has and how many times it should be rolled. The program will then simulate rolling a die (with the number of sides specified) that many times.Here is my code:#include#include#includeusing namespace std;string flipCoin();int rollDice();int diceSides;int main(){ int numToss = 0, diceRoll = 0; char choice = ‘ ‘; unsigned seed = time(0); srand(seed); while (choice != ‘E’) { cout <> choice; if (choice == ‘C’) { cout <> numToss; for (int x = 1; x <= numToss; x ) { cout << "flip" << x << " : " << flipCoin() << endl; } } else if (choice == 'D') { cout <> diceSides; cout <> diceRoll; for (int y = 1; y <= diceRoll; y ) { cout << "roll" << y << " : " << rollDice() << endl; } } else { cout <<"Thanks for playing!"<< endl; } } system("pause"); } string flipCoin(); { int toss = 0; toss = 1 rand() % 2; return (toss == 1 ? "heads" : "tails"); } int rollDice(); { int roll = 0; toss = 1 rand() % diceSides; return (roll); }
Java language question: Match regular expression to its description1. Any
Question Java language question: Match regular expression to its description1. Any string2. Strings that start with and end with A3. Palindrome4. Strings that contain 4 A’s, dont have to be consecutivethese are the optionsA — .*B — A.*A|AC — .*ABBABBA.*D– .*A.*A.*A.*A.*
How can I write a function that takes as input
Question How can I write a function that takes as input n and returns a string s representing the number n in binary?
In these blanks I put “public static void isAmountValid(>=1) and
Question In these blanks I put “public static void isAmountValid(>=1) and when I run it I get an illegal start of type error. I also put “public static double” in and got the same error. I guess I still have summer brain. What am I doing wrong?This is the question: Suppose that you want to add a method to BankLoan that returns true if a loan amount is valid and false otherwise. If the loan amount (a double) is taken as a parameter, then the method would not need direct access to instance data. Create the following method header: public static ________ isAmountValid(________ amount) Add code to the method to return true if the amount is greater than or equal to 0 and false otherwise: return amount ___ 0;
WHAT DOES A COMPUTER USER NEED TO KNOW ABOUT PROGRAMMING
Question WHAT DOES A COMPUTER USER NEED TO KNOW ABOUT PROGRAMMING IN ORDER TO PLAY A VIDEO GAME?
What is the big-O performance estimate of the this function?
Question What is the big-O performance estimate of the this function? />int f5 (n) { int sum = 0; for (i = 1; i < n; i = 2 * i) sum = i; return sum;} // end f5
Can you help me make a list or tuple that
Question Can you help me make a list or tuple that contains the months of the year in python coding?. (I’m not supposed to hardcode the month number)
I would like assistance on creating a loop to print
Question I would like assistance on creating a loop to print the number and the months of the year from a list
Aerodynamic Drag Forces The only forces we assume are from
Question Aerodynamic Drag Forces The only forces we assume are from gravity. The exercise will ignore the change of gravitational acceleration for motion near the surface of the earth. The forces exerted on a mass, m, are W⃗ , the weight and the drag force D⃗ .F⃗ = D⃗ W⃗ a=D W/ m In equation 1a the total force is, F⃗ . We want to determine the acceleration, ⃗a. Knowing the acceleration we follow the trajectory of m in steps of time, dt. This must be done numerically. Consider the displacement, ⃗r(t), and velocity, ⃗v(t), at any given moment of time, t,d⃗v = ⃗adt (2a). ⃗v(t dt) = ⃗v(t) d⃗v (2b)d⃗r = ⃗v(t)dt (2c) ⃗r(t dt) = ⃗r(t) d⃗r (2d)You can employ the steps in equations 2a-2d in a computer code you write or use one of the mathematical packages available. By selecting a step size, dt you are deriving an analytical solution(by quadrature) according You keep track of the total time. Following a 45 caliber bullet. Use MKS units!(A) A 45 caliber bullet has a mass of 13g and a cross sectional area of A = 1.06 × 10−4m2. Assume the muzzle velocity is v = 275m/s. For this cal- culation ignore drag. What is the maximum height, in meters, and the time of flight to maximum height in seconds? At what time after firing does the bullet return to ground? Assume the initial velocity is vertical.(B) The drag equation is D = Cd(v)pv2A / 2 (In equation 3) the coefficent of drag for this type of bullet depnds on the speed, v, Cd(v) and on air density, ρ is the air density. The direction of the drag force is opposite the velocity of the bullet. Note that if ρ = 0 we are back in the introductory physics situation. When you solve the problem, using whatever algorithm you chose, check, as a matter of principle, that if ρ = 0 your algorithm gives you the answer in (A). In order to apply equation 3 you should consider the importance of the dependence of the air density, ρ(h)(Question1) What is the maximum height the bullet reaches and the time to maximum height if it starts from sea level?(Question2) What is the time it takes for the bullet to fall back to the ground and its speed?(Question3) Suppose the bullet is fired from Colorado Springs(altitude 1840m). What is the maximum height of the bullet and the time to maximum height?(Question4) What is the time it takes for the bullet to fall back to the ground and its speed in Colorado Springs?(Question5) What is the terminal velocity of the bullet?
I am struggling with this Python coding question Exercise 5
Question I am struggling with this Python coding question Exercise 5 style=”color:rgb(0,0,0);”> (ceiling_fraction_test: 1 point). Complete the function, ceiling_fraction(a, b), which for any numeric inputs, a and b, corresponding to real numbers, a≥0a≥0 and b>0b>0, returns ⌈ab⌉⌈ab⌉, that is, the ceiling of abab. The type of the returned value must be int.
Project consisting of four classes. These four classes will be
Question Project consisting of four classes. These four classes will be ProgThree.java, Animal.java, Pet.java, and ZooAnimal.java. These four classes and they must work as it is described in these specifications. The first class, Animal, stores basic data about an animal. The second class Pet, stores additional data about an animal which is a pet. The third class ZooAnimal, stores additional data about an animal which is kept in a zoo. The fourth class ProgThree has a main method which reads data about animals, pets and zoo animals and creates a report about animals, pets and zoo animals.Animal.java technical details:One ConstructorConstructor #1. It will take all the parameters as listed:int animalID.String animalType.double weight.Instance variables for the Animal classint animalID.String animalType.double weight. Method which mustbe part of the Animal class:A toString() method which displays information about an animal in the following format:ID: 1015 Type: Monkey Weight: 38.6 Pet.java technical details:One Constructor – the first three parameters are passed to the Animal class constructor in the first line of the Pet constructor by using the super reference.Constructor. It will take all the parameters as listed:int animalID.String animalType.double weight.String name;String owner: Instance variables for the Pet classString name;String owner: Method which mustbe part of the Pet class:A toString() method which displays information about an animal in the following format:ID: 5089 Type: Fish Weight: 0.2 Name: Sally Owner: Henry SantosNote: The toString() Method gets the first line of output from the Animal class toString method. Animal is a parent class of the Pet class.ZooAnimal.java technical details:One Constructor – the first three parameters are passed to the Animal class constructor in the first line of the ZooAnimal constructor by using the super reference.Constructor #1. It will take all the parameters as listed:int animalID.String animalType.double weight.int cageNumber.String trainer.Instance variables for the ZooAnimal classint cageNumber.String trainer. Method which mustbe part of the ZooAnimal class:A toString() method which displays information about an animal in the following format:ID: 8850 Type: Fish Weight: 0.2 Cage: 103 Trainer: Suzie TranNote: The toString() Method gets the first line of output from the Animal class toString method. Animal is a parent class of the ZooAnimal class.ProgThree.java Specifications:The ProgThree should read information about animals, pets and zoo animals.Initial data about pets is available in a text file named animal.txt. The line of input from the text file and process it independently. The program should continue until all lines of the input file have been processed.The input file will contain a single line of data about each animal, pet or zoo animal. There are several lines in the input file and the animals, pets and zoo animals are mixed together. A input line will either contain three or five pieces of data. An input line with three pieces of data is an animal, and those three pieces of data will be animal id, weight, in order. Pets and zoo animals have the same first three pieces of data and then two additional pieces of data. If the animal id is between 3,000 and 7,999 the input record is about a pet and the last two pieces of data are the pet’s name and the owner’s name, both strings. If the animal id is between 8,000 and 9,999 the input record is about a zoo animal and the last two pieces of data are the cage number, an integer and the trainer’s name, a string.The rules for valid input records, follow:The first piece of data is animalID. It must be a four digit positive integer. Records whose ID numbers are between 3,000 and 7,999 should contain data about a “pet”. Records whose ID numbers are between 8,000 and 9,999 should contain data about a “zoo animal.” Records whose ID numbers are between 1,000 and 2,999 should contain data about an “animal.” Records whose ID numbers are less than 1,000 or greater than 9,999 should be considered to be invalid records.animalType must be a string of at least three characters.weight must be a valid positive real number.For “Pet” objects, name and owner each must be strings of at least three characters.For “Zoo Animal” objects, cageNumber must be a positive integer and trainer must be a string of at least three characters. Assume that input records will contain data of the data types needed by the program. For example, for input records of animals the record will contain an int, String and double in that order. You may not assume, however, that the input records will contain valid data. For example, the weight will be a real number (data type matches) but it may be negative making the input record invalid. In another input record, the animalType is a string but only contains two characters, making it an invalid record.After reading in the data, determine if the data contained in the record is valid. If so, construct the appropriate type of object and write the object’s data to the output file, “animalout.txt”. If not, ignore the input record and proceed to the next record. When all of the animals have been processed, write to the output the total number of each, animals, pets and zoo animals written to the output file. Close the output file and end the program.
The issue I am having is that it is getting
Question The issue I am having is that it is getting this error when I compile it in command prompt. GuessWhileDoNumber.java:7: error: class GuessNumberWhile is public, should be declared in a file named GuessNumberWhile.java public class GuessNumberWhile{This is my program that I am using. import java.util.Scanner; import java.util.Random; public class GuessNumberWhile{ public static void main(String args[]){ Random random = new Random (); int x = (random.nextInt (10)) 1; Scanner scan = new Scanner (System.in); boolean flag = true; int tries = 3; System.out.print (“Guess my secret number : “); int num = scan.nextInt (); while (flag
Can someone show me what this code should look like
Question Can someone show me what this code should look like I created it. Its a pseudocode for Java. The main objective of this program is making sure that employees and administration have access to the zoo’s system. The user’s information is stored into a text file and has the current password for each employee. Whenever an employee tries to enter the system, they will only get three attempts, if unsuccessful the system will kick them out. Each employee at the zoo will be prompted by the system, to enter username and password. If username and password are recognized by the system, the employee will then have access to their designated a in the text file. If by some reason if a user forgets his or her password, the user can simply type quit to exit. This program will help protect user information, as well as the information getting into the wrong hands.CREATE: using credentials.txt DISPLAY: login page for userPROMPT: for username IF user types quit, exit the programPROMPT: ask for password IF user types quit, exits the programLOOP: for no more than 3 password attempts for employee to gain access LOOP: to determine the true value for username and hashed passwordIF: username is entered rightCONVERT: user enters hashed passwordIF: user entered the wrong hashed password PROMPT: for user to try logging in againIF: all attempts are reached Alert user, they have met all attemptsEXIT: the programELSE: hashed password is right and enters the programSET: user in method of employee assigned jobDETERMINE: user role in method of the employees assigned job Based on information from credentials.txtCALL: to the welcome page/ job role and limited access the employee hasEXIT: the program
Hello,I do not understand how to the part: ” java
Question Hello,I do not understand how to the part: ” java Assignment1 myout1.txtHere the program reads from input1.txt file, and write its output into the file named “myout1.txt”. Note that you need to have Assignment1.java file and input1.txt file in the same folder.”I am unsure how to run this script in eclipse. Can you help me do this or find me the right location to do so.Thank you!
Hi, good day.I’m trying to write a new row to
Question Hi, good day.I’m trying to write a new row to old csv files in python, and it will be updated every time when I run the program.I were tried to append the new row,but it was deleted my old data…Anyone can guide me about this ?
Need a java console application, more information when i get a tutor,you
Need a java console application, more information when i get a tutor,you should be an expert in java
the code just copy it to eclipse and run it!
I wrote the code all of it, and it is correct, for some reason my eclipse stopped working and i need a screenshot of the code running….!!
What is the big-O performance estimate of the following function?
Question What is the big-O performance estimate of the following function? What is each line doing? int f5 (n) { int sum = 0; for (i = 1; i < n; i = 2 * i) sum = i; return sum; } // end f5
The post Assistance requested with understanding the outcome of code listed below. appeared first on Smashing Essays.