Question

Hi I have 4 problems below I need done ASAP, if you could upload them one...

Hi I have 4 problems below I need done ASAP, if you could upload them one by one by order you finish them instead of all at once that would be appreciated,

I need this done in basic c++ code, all of the body structure are below I just need codes to be implemented for the codes to give the write outputs,

Thank you.

Q1. Update the given code 1 to implement the following problem:

  • Create a class animal
  • Set private variables color, num_legs, tail
  • Tail must be a Boolean variable
  • Create an object animal
  • Ask user to get the name, color and number of legs of that animal and if that animal has a tail
  • Parse all these parameters to the animal class without using a constructor
  • Print to show that you successfully did the task

Code 1:

class animal {

string color;

int num_legs;

/* Write your code here

*/

};

int main(){

/*write your code here

}

Q2. Update the given code 2 to implement the following problem:

  • Create a class triangle
  • Use dynamic memory allocation to create 10 objects of the class triangle
  • Set default height and base of all created objects (triangle) to 5 and 10 respectively using a constructor
  • Ask user to change only the height of the 5th triangle
  • Print height and base of all (10) triangles to demonstrate that you did the task correctly
  • Deallocate the 5th object
  • Print height and base of all (10) objects of the class triangle to demonstrate that you deallocated the 5th object correctly

Code 2:

class triangle {

int base;

int height;

/* Write your code here

*/

};

int main(){

/*write your code here

}

Q3. Update the given code 3 to implement the following problem:

  • Create a class car
  • Create a Constructor to set the default color of the car
  • The color of the car must be a string given by the user
  • Ask another user to set the color of the car
  • If the color specified by the 2nd user is not the same as the color specified by the 1st user, then change the color of the car specified by the second user

Code 3:

class car {

string color;

/* Write your code here

*/

};

int main(){

/*write your code here

}

Q4. Write a code to implement the following problem:

  • Take a 10 strings from 10 users
  • Concatenate those strings to a single string
  • Delete all vowels (i.e. a, e, i, o, u)   from the final string
  • Print the new string

class delete_vowels{

                /* write your code here */

                public:

                /* write your code here */

};

                int main(){

                                string s;

                /*write your code here

                }

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change.


Note:
As HOMEWORKLIB strict policy & guidelines, I am only allowed to answer the first question. please post the remaining 3 questions as a separate post, and I will be happy to answer them quickly.

thank You!

===========================================================================

#include<iostream>
#include<string>

using namespace std;


class animal{
  
   private:
       string color;
       int num_legs;
       bool tail;
   public:
       void set_color(string);
       void set_num_legs(int);
       void set_tail(bool);
      
       string get_color();
       int get_num_legs();
       bool has_tail();
};

void animal::set_color(string col){color=col;}
void animal::set_num_legs(int legs){num_legs=legs;}
void animal::set_tail(bool tails){tail=tails;}

string animal::get_color(){return color;}
int animal::get_num_legs() {return num_legs;}
bool animal::has_tail(){return tail;}

int main(){
  
   string color; int legs; string has_tail;
   cout<<"Enter color: "; cin>>color;
   cout<<"Enter number of legs: "; cin>>legs;
   cout<<"Has tail (yes or no): "; cin>>has_tail;
  
   animal aAnimal;
   aAnimal.set_color(color);
   aAnimal.set_num_legs(legs);
   aAnimal.set_tail(has_tail.compare("yes")==0);
  
  
   cout<<"Details: \n";
   cout<<"Animal color: "<<aAnimal.get_color()<<endl;
   cout<<"Number of legs: "<<aAnimal.get_num_legs()<<endl;
   cout<<"Has Tail: "<<(aAnimal.has_tail()?"Yes":"No")<<endl;
  
}

=========================================================================

Add a comment
Know the answer?
Add Answer to:
Hi I have 4 problems below I need done ASAP, if you could upload them one...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • I need this in java please Create an automobile class that will be used by a...

    I need this in java please Create an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class: private string make private string model private string color private int year private int mileage. Your program should have appropriate methods such as: default constructor parameterized constructor add a new vehicle method list vehicle information (return string array) remove a vehicle method update vehicle attributes method. All methods...

  • I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java...

    I need help writing my main method**** Computer Science 111 Introduction to Algorithms and Programming: Java Programming Project #4 – Classes and Objects (20 Points) You will create 3 new classes for this project, two will be chosen from the list below and one will be an entirely new class you invent.Here is the list: Shirt Shoe Wine Book Song Bicycle VideoGame Plant Car FootBall Boat Computer WebSite Movie Beer Pants TVShow MotorCycle Design First Create three (3) UML diagrams...

  • Hi I need help doing this problem *The program must re-prompt as long as invalid input...

    Hi I need help doing this problem *The program must re-prompt as long as invalid input is inserted Implement a program that manages shapes. Implement a class named Shape with a virtual function area()which returns the double value. Implement three derived classes named Diamond, Oval, and Pentagon. Declare necessary properties in each including getter and setter function and a constructor that sets the values of these properties. Override the area() function in each by calculating the area using the defined...

  • C# - Inheritance exercise I could not firgure out why my code was not working. I...

    C# - Inheritance exercise I could not firgure out why my code was not working. I was hoping someone could do it so i can see where i went wrong. STEP 1: Start a new C# Console Application project and rename its main class Program to ZooPark. Along with the ZooPark class, you need to create an Animal class. The ZooPark class is where you will create the animal objects and print out the details to the console. Add the...

  • I need some help i need to do this in C# Objectives: • Create an application...

    I need some help i need to do this in C# Objectives: • Create an application that uses a dictionary collection to store information about an object. • Understanding of abstract classes and how to use them • Utilize override with an abstract class • Understanding of Interfaces and how to use them • Implement an Interface to create a “contract” between classes. • Compare and contrast inheritance and interfaces. Instructions: Interface: Create an interface called ITrainable which contains the...

  • I have done a decent amount of coding... but I need you to help me understand...

    I have done a decent amount of coding... but I need you to help me understand what I do not. Please, post comments so that I can learn from you. Here are the instructions for this portion of the project: Create the Monkey class, using the specification document as a guide. The Monkey class must do the following: Inherit from the RescueAnimal class Implement all attributes with appropriate data structures Include accessors and mutators for all implemented attributes Here is...

  • I need the following written in Java please, thank you ' We want you to implement...

    I need the following written in Java please, thank you ' We want you to implement a java class that will show details on users and throw exceptions where needed. The following requirements specify what fields you are expected to implement in your User class: - A private String firstName that specifies the first name of the user - A private String lastName that specifies the last name of the user - A private int age that specifies user's age...

  • I need to get this two last parts of my project done by tonight. If you...

    I need to get this two last parts of my project done by tonight. If you see something wrong with the current code feel free to fix it. Thank you! Project 3 Description In this project, use project 1 and 2 as a starting point and complete the following tasks. Create a C++ project for a daycare. In this project, create a class called child which is defined as follows: private members: string First name string Last name integer Child...

  • Create a class called Flower. Add one member variables color. Add only one getter function for the color. The get function returns color. Implement a constructor that expects color value and assigns it to the member variable. Create a subclass of Flower

    Create a class called Flower. Add one member variables color. Add only one getter function for the color. The get function returns color. Implement a constructor that expects color value and assigns it to the member variable. Create a subclass of Flower named Rose. The Rose class has one member variable name.  Add a constructor which expects color and  name. Pass color to the base constructor and set name to it's member variable.Write a program that has an array of ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT