Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

2. Write a class named Pet, which should have the following data attributes:

a) __name (for the name of a pet) __animal_type (for the type of animal that a pet is. Example values are ‘Dog’, ‘Cat’, and ‘Bird’) __age (for the pet’s age)

The Pet class should have an __init__ method that creates these attributes. It should also have the following methods:

b) set_name: This method assigns a value to the __name field. set_animal_type: This method assigns a value to the __animal_type field. set_age: This method assigns a value to the __age field. get_name: This method returns the value of the __name field. get_animal_type: This method returns the value of the __animal_type field. get_age: This method returns the value of the __age field.


1.Write a class named Car that has the following data attributes:

a) __year_model (for the car’s year model) __make (for the make of the car) __speed (for the car’s current speed)

The Car class should have an __init__ method that accepts the car’s year model and make as arguments. These values should be assigned to the object’s __year_model and __make data attributes. It should also assign 0 to the __speed data attribute.

The class should also have the following methods:

b)Accelerate: The accelerate method should add 5 to the speed data attribute each time it is called. Brake: The brake method should subtract 5 from the speed data attribute each time it is called. get_speed: The get_speed method should return the current speed


1. Design a recursive function that accepts an integer argument, n, and prints every second number from n down to a minimum of 0. Assume that n is always a positive integer.


Write a C++ program which will accept miss Dodoma contestant. The contestant is described through: contestant surname, contestant identification number, gender, age, weight, height,

registrationstatus. The registration status is valued as either true or false. Your program should:

- Accept the values via assignment operator.

- Display the accepted values on the screen

- Overwrite the previously values by the values accepted from user.

-Display the current values on the screen.



A school called ‘Danville’ has a provision of keeping 2 kinds of Presidents: School President and Class president. (President class can be either a concrete class or an abstract class or an interface. You need to determine what it will be from the following clues.) There can be only 1 school president but there can be multiple class presidents. School and class presidents do not have any common attribute but they have a common school name which is fixed as ‘Danville’. Class presidents have a class id which school presidents do not have. Both school president and class president have a common method named exercisePower but their implementations are different. It prints “Exercising power on school” for the former and “Exercising power on class __” for the latter.


Write a C function remove_blanks()that replaces two or more consecutive blanks in the input string by a single blank. For example, if the input is:


        “Grim     return   to      the       planet           of         apes!!”


Then output should be:


“Grim return to the planet of apes!!”


The function should return the number of blank spaces removed. Remember that string is a null-terminated character array! The function prototype is given below:


int remove_blanks(char input_string[],char output_string[]);


write a c++ program to create a class called person contain (name, age) as a variables and get and print information as functions?


Largest Missing Negative Number

You are given an unsorted array

A of N integers. You have to find the largest negative integer missing from the array.
Input

The first line contains

N space-separated integers of A.
Output

The output contains

N space-separated integers representing the number of people as mentioned above.
Explanation

Given

A = -2 -1 0 1 2.The largest negative number missing is

-3.


Sample Input 1

-2 -1 0 1 2


Sample Output 1

-3


Sample Input 2

-11 -10 -12


Sample Output 2

-1


Balanced Brackets

You are given an expression string

S which contains expressions that made of bracket characters {, }, (, ), [, ]. Each expression in string is separated by space.Two brackets considered to be a matched pair if an opening bracket (i.e., (, [, or {) occurs to left of a closing bracket (i.e., ), ], or }) of exact same type. There are 3 types of matched pairs of brackets: [], {}, and ().

Write a program to examine whether each expression in

S is balanced.
Input

The first line contains a string

S with space-separated bracket expressions.
Output

Each line of the output represents the status of each bracket expression in input string.

Print

YES if the expression is balanced, else print NO.
Explanation

Given

S = {()} ({}.The first expression

{()} is balanced, so its output is YES. The second expression ({}} is unbalanced, so its output is NO.


Sample Input 1

{()} ({}


Sample Output 1

YES

NO


Sample Input 2

{}[] [({})] {}


Sample Output 2

YES

YES

YES


Concatenate Word Pairs

Given a sentence and an integer L, write a program to concatenate word pairs so that the concatenated word has the length L.

Input

The first line of input will be a sentence.

The second line of input will be an integer L.

Output

The output should be containing the unique concatenated word pairs each in a line in the lexicographical order.

Explanation

For example, if the given sentence and L are


Welcome to your exam

6


The words which can be paired so that they make concatenated word with length 6 are

Word1Word2toyourtoexamexamtoyourto

So the output should be printing each concatenated word in a line in the lexicographical order


examto

toexam

toyour

yourto


Sample Input 1

Welcome to your exam

6


Sample Output 1

examto

toexam

toyour

yourto


Sample Input 2

My parents and I went to a movie

9


Sample Output 2

Myparents

moviewent

parentsMy

parentsto

toparents

wentmovie




LATEST TUTORIALS
APPROVED BY CLIENTS