Concept explainers
Complete the following
#include <iostream>
using namespace std;
class Yard
{
private:
int length, width;
public:
} ;
Yard ()
{ length = O; width= O; }
void setLength(int 1}
{ 1ength = 1 ; }
void setWidth(int w)
{ width = w; }
int main ()
{
// Finish this program.
}
Want to see the full answer?
Check out a sample textbook solutionChapter 8 Solutions
Starting Out With C++, Early Objects - With Access Package
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Starting Out With Visual Basic (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Starting Out with Python (3rd Edition)
Starting Out With Visual Basic (7th Edition)
- Q 1) Write a class with name Array. This class has an array which should be initialized by user. Create a function with name sumFind in this class with working logic as sum of all elements of an array, after finding sum, if sum is even calculate factorial otherwise display only sum. ( Note::: subject::c# language )arrow_forwardLanguage: JAVA Script Your company is giving every employee earning less than $50,000 a 10% raise! *Write a function 'employeeRaises(peopleObj)' that takes an array of objects s containing employee names and their salaries and returns an array containing the employees that need raises, along with their new salaries. Example: employees [ {name: "Alice", salary: 80000}, {name: "Bob", salary: 48000 }, {name: "Carol", salary: 60000}, {name: "Dan", salary: 78000}, {name: "Ellen", salary: 100000}, console.log(employeeRaises (employees) ); // [ { name: 'Bob', salary: 44000 } ] funcation emplyeeRaises(employees){ |// Your code here} /****DO NOT MODIFY ANYTHING UNDER THIS LINE****/ try{| module.exports = employeeRaises;}catch (e) {|module.exports=null;}arrow_forward1) Write a function called initializeArray that receives an array, its size, and two integers andinitializes the array with random values between the first integer and the second integer. Write anotherfunction called printArray that receives an array and its size and prints the array elements in a column. Writea test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive,and then prints the array using the above functions. 2). Write a function called evenOdd that receives an integer and determines if it is even or odd.Write a test program that initializes an integer array of size 50 with random integers between 1 and 99 inclusive using initializeArray (from question 1) and determines and displays the number of odd or evennumbers in the array using evenOdd.arrow_forward
- an int variable k, an int array currentMembers that has been declared and initialized, an int variable nMembers that contains the number of elements in the array, an int variable memberID that has been initialized, and a bool variable isAMember, Write code that assigns true to isAMember if the value of memberID can be found in currentMembers, and that assigns false to isAMemberotherwise. Use only k, currentMembers, nMembers, and isAMember.arrow_forwardWrite a simple trivia quiz game using c++ Start by creating a Trivia class that contains information about a single trivia question. The class should contain a string for the question, a string for the answer to the question, and an integer representing the dollar amount the question is worth (harder questions should be worth more). Add appropriate constructor and accessor functions. In your main function create either an array or a vector of type Trivia and hard-code at least five trivia questions of your choice. Your program should then ask each question to the player, input the player’s answer, and check if the player’s answer matches the actual answer. If so, award the player the dollar amount for that question. If the player enters the wrong answer your program should display the correct answer. When all questions have been asked display the total amount that the player has won.arrow_forwardIn Java Assignment 5B : Maze Game! 2D Arrays can be used to store and represent informationabout video game levels or boards. In this exercise, you will use this knowledge tocreate an interactive game where players attempt to move through a maze. You willstart by creating a pre-defined 2D array with the following values:{"_","X","_","X","X"}{"_","X","_","X","W"}{"_","_","_","X","_"}{"X","X","_","_","_"}{"_","_","_","X","X"}You will then set the player (represented by “O”) at index 0, 0 of the array, the top-leftcorner of the maze. You will use a loop to repeatedly prompt the user to enter adirection (“Left”, “Right”, “Up”, or “Down”). Based on these directions, you will try tomove the player.• If the location is valid (represented by “_”), you will move the player there• If the location is out of bounds (e.g. index 0, -1) or the command is invalid, youwill inform the player and prompt them to enter another direction• If the location is a wall (represented by “X”), you will tell the…arrow_forward
- A main() function is given below. Based on this function, your task is to write complete coderequired to run the main() function successfully. class MyArray{private:float* array;int size;Declare a static variable to count the number of objectspublic:Implement a static function to return total count of objects};int main(){int size;float* ptr;cout << "Enter the size of your array" << endl;cin >> size;ptr = new float[size];cout << "Enter elements of array" << endl;for (int i = 0; i < size; i++){cin >> ptr[i];}MyArray a1(ptr, size);MyArray a2 = a1;int len = a1.getSize();float* res;res = new float[len]; res = a1.getArray();for (int i = 0; i < len; i++){cout << res[i];}// incase of array, compare or add or perform any operation index wiseif (a1 == a2) // overload == operator to compare two objects{cout << "Both arrays are equal" << endl;}else{cout << "Both arrays are not equal" << endl;}MyArray a3;a3 = a1 + a2; //…arrow_forwardYou are working for a university to maintain a list of grades and some related statistics for a student. Class and Data members: Create a class called Student that stores a student’s grades (integers) in a vector (do not use an array). The class should have data members that store a student’s name and course for which the grades are earned. Constructor(s): The class should have a 2-argument constructor that receives the student’s name and course as parameters and sets the appropriate data members to these values. Member Functions: The class should have functions as follows: Member functions to set and get the student’s name and course variables. A member function that adds a single grade to the vector. Only positive grades are allowed. Call this function AddGrade A member function to sort the vector in ascending order. A member function to compute the average (x̄) of the grades in the vector. The formula for calculating an average is x̄ = ∑xi / n where xi is the value of each…arrow_forward1) Write a function called initializeArray that receives an array, its size, and two integers andinitializes the array with random values between the first integer and the second integer. Write anotherfunction called printArray that receives an array and its size and prints the array elements in a column. Writea test program that declares and initializes an array of size 20 with random values between 0 and 10 inclusive,and then prints the array using the above functions. 2)Write a function called shiftRight that receives an array and its size and shifts the elements of thearray to the right while the last element will move to the first location. Write a test program that declares andinitializes an integer array of size 10 with random integers between 1 and 10 using initializeArray (fromquestion 1). Use shiftRight to shift the elements of this array to right and use printArray to print the arraybefore and after shift.Here is a sample run of the program:Original array: [2, 3, 5, 2, 2, 8,…arrow_forward
- Write a program in C++ that simulates a lottery. The program should have an array of five integers named winningDigits, with a randomly generated number in the range of 0 through 9 for each element in the array. The program should ask the user to enter five digits and should store them in a second integer array named player. The program must compare the corresponding elements in the two arrays and count how many digits match. For example, the following shows the winningDigits array and the Player array with sample numbers stored in each. There are two matching digits, elements 2 and 4. WinningDigits 7 4 9 1 3 player 4 2 9 7 3 Once the user has entered a set of numbers, the program should display the winning digits and the player’s digits and tell how many digits matched.arrow_forwardA struct to store a single playing card is as follows: struct card { char suit; char kind; }; The valid suits are 'S', 'H', 'D' and 'C', while the valid kinds are 'A', '2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', and 'K'. A poker hand can be stored as an array of five struct cards. A flush is a hand that contains five cards, all of the same suit. Write a function that returns 1, if the poker hand passed to it has five cards of the same suit, and 0 otherwise. int isFlush(struct card hand[]); int isFlush(struct card hand[]) {arrow_forward2.2 A struct employeeType has been declared with two elements: name and salary.a. Declare an employeeType struct array for 100 employees. b. Write a code snippet of the loop that will accept the details of the 100 employees.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning