Question: Lecture 4 - Assignment Part 1 - Questions Answer correctly the following 10 questions (When you turn in your work - be sure to write

Lecture 4 - Assignment Part 1 - Questions Answer correctly the following 10 questions (When you turn in your work - be sure to write the question and then the answer)

1) Why is there an Object Oriented Programming Paradigm ? 2) What is the syntax of a class ? 3) What are the 3 steps for classes ? 4) What are the reasons for class private access specifications ? 5) What are the reasons for class public access specifications ? 6) How do you think classes simplify programming or make more complex ? 7) What does the DOT notation do ? 8) Why make variables private ? 9) Why make functions public ? 10) How is a class like a concept ? Turn in as ONE file... Week4YourNameClassQ10 ======================================

Part 2 - Programs NOTE: It is REQURED that Each program must include this line: cout << "Name: YOURNAME - Program Name: PROGRAM NAME - Date: MMDDYY" << endl; Example: cout << "Name: Jon Smith - Program Name: Prog9Box - Date: 6/28/17" << end; ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Code the following 7 programming problems (graded) Run each program and Produce output - Place code and Screen Prints of successful runs in MS Word file. Turn in each program in a SEPERATE FILE for credit - Name EACH file like: Week4YourNameProgBucky1ClassAndOjects Week4YourNameProgBucky2VariablesInAClass Week4YourNameProg3Athing Week4YourNameProg4Color Week4YourNameProg5Rect Week4YourNameProg6Box Week4YourNameProg7Circle --------------------------------------------------------------------------------------------

Program 1 - Bucky 1 - Classes and Objects Watch the following video: Buckys C++ Programming Tutorials - 12 - Introduction to Classes and Objects (Links to an external site.)Links to an external site. Write the program in the video, run the code, get correct results and turn in for credit Turn in version of code at end of video.. ----------------------------------------------------------------------------------------------

Program 2 - Buck 2 - Variable in a class Buckys C++ Programming Tutorials - 13 - Using Variables in Classes (Links to an external site.)Links to an external site. Watch the following video: Write the program in the video, run the code, get correct results and turn in for credit Turn in version of code at end of video.. ----------------------------------------------------------------------------------------------

Program 3) Run the following Sample Code - Produce the correct output and Turn it in for credit // Sample Class - Print and Study, RUN the code... #include #include using namespace std; // STEP 1 - DEFINE THE new datatype/Class 'aThing' class aThing { public: // Public means that is can be access in step 3 with the dot notation double getWeight(void) { return weight; } // public functions accessible by dot notation void setWeight( double inWeight ) { weight = inWeight; } private: // Private means that it can NOT be accessed with the dot notation, but indirectly with a public function double weight; // private variables only accessible by a function }; int main() { // STEP 2 - DECLARATION - USE the new datatype/class 'aThing' in a Declaration statement to create 'ThingOne'. aThing ThingOne; // STEP 3 - Use the OBJECT defined in step 2 - With dot notation ThingOne.setWeight(110); cout << "Use Function/Method get Weight - "<< "Weight is: " << ThingOne.getWeight() << endl; system("PAUSE"); // MAC User comment this line out. return 0; } -------------------------------------------------------------------------------------------

- Program 4 - Pick color Class Create a class that randomly pick a color from an array of colors: string colors[7]; Have the colors array and all functions defined in the class. Create and use a void setElement( index, "color") function to assign values to the array elements 0 to 6: red, orange, yellow, green, blue, indigo, violet. Have a function that prints out all the colors in the array. Have a function that randomly pick One color from the array and cout's the color. (Research Random number code) Run your Code - Produce the correct output and Turn it in for credit ---------------------------------------------------------------------------------------

Program 5 Rectangle - Complete the following code then run it - Produce the correct output and Turn it in for credit // classes example #include using namespace std; class Rectangle { int width, height; public: void set_values (int,int); int area() { int answer; // complete this function so the code works return answer; } }; void Rectangle::set_values (int x, int y) { // complete this function so the code works } int main () { // Use this driver program // Use set_values function to set values Rectangle rect1; rect1.set_values (5,6); cout << "area: " << rect1.area() << endl; // Use set_values function to set values Rectangle rect2; rect2.set_values (3,4); cout << "area: " << rect2.area() << endl; return 0; } -------------------------------------------------------------

Program 6 BOX - Complete the following code then run it - Produce the correct output and Turn it in for credit - Note: A Box is a 3D object... Write a class for a BOX (box is another name for a cube) It should contain: Width, Height, and Depth It should contain 3 methods to input/set the Width, Height, and Depth Values. It should contain a method to calculate the Volume of the box. It should contain a method to calculate sum of the Area the 6 sides of the box,. It should contain three method to return/get the individual values of the Width, Height and Depth variables in the class All dimensions must be greater than zero, before the area or volume can be calculate... the calc functions should cout an error message is they are not. Test the box with the following driver code: HINT: Use function names and class name found in driver below. int main() { // Box 1 - Test set functions, Volume, getHeight and area functions box B1; // HINT MAKE A Default constructor or set functions... B1.setWidth(2); B1.setHeight(3); B1.setDepth(4); cout << "Height = " << B1.getHeight << endl; cout << "Area = " << B1.calcArea() << endl; cout << "Volume = " << B1.calcVolume() << endl; // Box 2 - Test zero value error for calc Area and Volume of sides functions box B2; B2.setWidth(3); B2.setHeight(4); cout << "Depth = " << B2.getDepth << endl; cout << "Area = " << B2.calcArea() << endl; cout << "Volume = " << B2.calcVolume() << endl; } -----------------------------------------------------------------------------

Program 7 - Circle You write ALL the code, then run it - Produce the correct output. Turn in code and screen print of successful run, for credit * Write a class for a Circle * Input only the radius. * Write functions that Calculate the circles Circumference, Area and Diameter, and print out the value of the radius * Include error checking for radius, must be greater than zero. Test all combinations -------------------------------------------------------

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!