Question

a. Write a constructor which initializes the canvas_frame, canvas, and title. The constructor receives a string parameter to

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

We are allowed to do only 4 questions if more question is asked in a single question and even language is not defined to create the objects. So doing question no. 8 in c++, as language will not matter much in it.

 #include<bits/stdc++.h> using namespace std; // print all the elements greater than 80 or less than 10 from the array void lgt(int num[13][7]){ for(int i = 0; i < 13; i++){ for(int j = 0; j < 7; j++){ if(num[i][j] > 80 || num[i][j] < 10){ cout << num[i][j] << endl; } } } } // this function returns the largest element in the array int largest(int num[13][7]){ int max = INT_MIN; for(int i = 0; i < 13; i++){ for(int j = 0; j < 7; j++){ if(num[i][j] > max){ max = num[i][j]; } } } return max; } //this function returns the average of all elements in the array float average(int num[13][7]){ int total = 0; for(int i = 0; i < 13; i++){ for(int j = 0; j < 7; j++){ total += num[i][j]; } } return float(total)/(13*7); } // this function prints the array in table form from last row to first row void print(int num[13][7]){ for(int i = 12; i >=0; i--){ for(int j = 0; j < 7; j++){ cout << num[i][j] << " "; } cout << endl; } } int main() { int num[13][7]; // declare the array // fill array with the random number for(int i = 0; i < 13; i++){ for(int j = 0; j < 7; j++){ num[i][j] = rand() %100; } } lgt(num); int max = largest(num); cout << "Largest no. " << max << endl; float avg = average(num); cout << "average: " << avg << endl; print(num); return 0; } 

OUTPUT:

83
86
93
86
92
90
82
2
93
84
98
91
96
81
5
84
5
95
82
87
8
88
84
3
99


Largest no. 99


average: 51.4725


88 84 3 51 54 99 32
64 43 50 87 8 76 78
24 95 82 45 14 67 34
27 36 5 46 29 13 57
62 70 96 81 5 25 84
70 13 26 91 80 56 73
21 19 84 37 98 24 15
67 93 56 11 42 29 73
67 35 29 2 22 58 69
68 67 29 82 30 62 23
63 26 40 26 72 36 11
92 49 21 62 27 90 59
83 86 77 15 93 35 86


Add a comment
Know the answer?
Add Answer to:
a. Write a constructor which initializes the canvas_frame, canvas, and title. The constructor receives a string...
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
  • Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which...

    Q1. Write a recursive function in C++ void printNumberedChars(string str, int i=0) { ... } which prints each character of the given string str on a new line, with each line numbered 1, 2, 3, …. For example calling the function with printNumberedChars("hello"); should output the following: 1. h 2. e 3. l 4. l 5. o Q2. Write a recursive function in C++ int sumArray(const int* arr, unsigned int size) { ... } which takes an array of integers,...

  • Assume you have the following declaration (in main) : int num[10] [7]; Assume that array num...

    Assume you have the following declaration (in main) : int num[10] [7]; Assume that array num is filled completely. Write functions to perform each of the following: a) A function that prints all elements in the array that are greater than 10 or less than 50. b) A function that finds the largest number in the array and returns its subscript. c) A function that finds and returns the average of all the numbers in the array. d) A function...

  • I am having difficulty with completing this task. thank you. Task 10.1 (a) Define a C++...

    I am having difficulty with completing this task. thank you. Task 10.1 (a) Define a C++ base class named Rectangle containing length and width data members. From this class, derive a class named Box with another data member named depth. The member functions for the base class Rectangle should consist of a constructor and an area() function. The derived class Box should have a constructor, a volume() function and an override function named area() that returns the surface area of...

  • 1. Define a class Rectangle with two attributes: (This is for C++) -length, an integer (default...

    1. Define a class Rectangle with two attributes: (This is for C++) -length, an integer (default value 1) -width, an integer (default value 1) Provide the following member functions: -default constructor -constructor that takes parameters used to initialize the data -get/set function for each attribute -a function perimeter that returns the perimeter of the rectangle -a function area that returns the area of the rectangle b. Write a program that uses the class Rectangle to create two rectangle objects with...

  • Question 1) Consider a class Point that models a 2-D point with x and y coordinates. Define the c...

    C++ Question 1) Consider a class Point that models a 2-D point with x and y coordinates. Define the class point that should have the following Private data members x and y (of type int), with default values of 0 A constant ID of type int A private static integer data member named numOfPoints This data member should be o Incremented whenever a new point object is created. o Decremented whenever a point object is destructed. A default constructor An...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Exercise #1:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: 1. Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. 2. A non-argument constructor method to create a default rectangle. 3. Another constructor method to...

  • Creating a Class in C++ Summary In this lab, you create a programmer-defined class and then...

    Creating a Class in C++ Summary In this lab, you create a programmer-defined class and then use it in a C++ program. The program should create two Rectangle objects and find their area and perimeter. Instructions Ensure the class file named Rectangle.cpp is open in your editor. In the Rectangle class, create two private attributes named length and width. Bothlength and width should be data type double. Write public set methods to set the values for lengthand width. Write public...

  • This exercise guides you through the process of converting an Area and Perimeter application from a...

    This exercise guides you through the process of converting an Area and Perimeter application from a procedural application to an object-oriented application. Create and use an object 1. Open the project named ch04_ex2_Area and Perimeter that’s stored in the ex_starts folder. Then, review the code for the Main class. 2. Create a class named Rectangle and store it in the murach.rectangle package. 3. In the Rectangle class, add instance variables for length and width. The, code the get and set...

  • Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double...

    Book: - title: String - price: double +Book() +Book(String, double) +getTitle(): String +setTitle(String): void +getPrice(): double +setPrice(double): void +toString(): String The class has two attributes, title and price, and get/set methods for the two attributes. The first constructor doesn’t have a parameter. It assigns “” to title and 0.0 to price; The second constructor uses passed-in parameters to initialize the two attributes. The toString() method returns values for the two attributes. Notation: - means private, and + means public. 1....

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