Concept explainers
Repeat
Next, modify the main function so that instead of creating separate variables for each Movie object, an array of at least four Movie objects is created with sample data. Loop through the array and output the name, MPAA rating, and average rating for each of the four movies.
Want to see the full answer?
Check out a sample textbook solutionChapter 11 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Programming in C
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- In C++ Create a class called Student. Each student should have a name and ID number (an int). They should also have a ptr to a dynamic array called Grades. The public methods for Student should be: getName, setName, getID, setID, setGrades, getGrades. In the constructor you should initialize Grades to be an array of size 4 with the values 0 for each position. Make sure that you use THIS properly. Create 2 students, assign one object to another and show that when you assign grades to one it effects the other equally.arrow_forwardImplement this program to understand use of Arrays in real world examples. A small airline has just purchased a computer for its new automated reservations system. You have been asked to develop the new system. You are to write an application to assign seats on each flight of the airline’s only plane (capacity: 10 seats). Your application should display the following alternatives: Please type 1 for First Class and Please type 2 for Economy. If the user types 1, your application should assign a seat in the first-class section (seats 1–5). If the user types 2, your application should assign a seat in the economy section (seats 6–10). Your application should then display a boarding pass indicating the person’s seat number and whether it is in the first-class or economy section of the plane. Use a one-dimensional array of primitive type boolean to represent the seating chart of the plane. Initialize all the elements of the array to false to indicate that all the…arrow_forward1. Declare an array to save 4 Dog objects. The Dog class is provided below. Look into the Dog class and find what attributes are needed for a dog object. Then initialize five dogs with the following information: Lily, 5 years old Jacob, 2 years old Sugar, 8 years old Bush, 3 years old 2. Print out every dog using a for loop (use either regular for loop or for-each loop, your choice). But you may find when you print out, the name and age are not displayed. Why? 3. Fix this problem by implementing the toString method in the Dog class. Dog Class: public class Dog { private String name; private int age; public Dog(String name, int age) { this.name = name; this.age = age; } public void setName(String name) { this.name = name; } }arrow_forward
- write a cilent program for a class that reads up to 100 data of charter flights from the file whose name is obtained form the user, stores them in an array, then displays all the records along with the revenue amounts, and then allows the user to search and display charter flights by the name of the buyer, until user enters a sentinel.arrow_forwardProblem: We need a program that takes 8 products and makes calculations and informs the user. Products have name, type and cost. Write the program that takes name,type and cost information from the user and saves the product objects to an array and calculates the total cost, the one with the most cost and the one with the least cost. For example: Banana Fruit 10 Apple Fruit Trousers Textile 50 T-Shirt Textile 30 Pencil Office 15 Office Раper Strawberry Computer 10 Fruit 20 Electronics 6000 Total Cost: 6140 TL Most Expensive: Computer Least Expensive: Applearrow_forwardAssignment A scientist has developed a mathematical model for a physical process, and he wants to check how good is model is. To evaluate the correctness of his model, he wants to test the results of his model under certain parameters and compare them with experimental results. Write a program that first reads the number of tests (testCount) as an int followed by the results of each test according to the model as a double array (testModel) and finally the results of each test according to experiments as a double array (testExperiment). Then, the program should calculate the error of the model by evaluating the average of the absolute values (i.e., mutlak değer) of the differences between the model result and experimental result (see formula below) using a function. ItestModel,- textExperiment, testCount NOTE: Individual absolute value of the difference between the model value and the experiment value calculations MUST be done in the function. Every other functionality MUST be done in…arrow_forward
- Assignment A scientist has developed a mathematical model for a physical process, and he wants to check how good is model is. To evaluate the correctness of his model, he wants to test the results of his model under certain parameters and compare them with experimental results. Write a program that first reads the number of tests (testCount) as an int followed by the results of each test according to the model as a double array (testModel) and finally the results of each test according to experiments as a double array (testExperiment). Then, the program should calculate the error of the model by evaluating the average of the ratio of absolute values (i.e., mutlak değer) of the differences between the model result and experimental result to the model result (see formula below) using a function. testCount testModel, - textExperiment, testModel, Error= Input testCount NOTE: Individual ratio of absolute value of the difference between the model value and the experiment value to the model…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 the 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_forwardWhen an array is passed as a parameter to a method, modifying the elements of the array from inside the function will result in a change to those array elements as seen after the method call is complete. O True O Falsearrow_forward
- The formula to calculate the volume V and surface arca A of a cylinder are Volume V = ưh %3D Surface area A = 2rrh + 2ar? where h is the height and r is the radius. Write a class Cylinder to represent a cylinder that contains height and radius as the attributes (data members) and some necessary member functions to operate on the data members of the class. Your program should declare an array of 3 Cylinder objects. Based on the given sample output, the program should prompt for the radius and height for every Cylinder object. You should write the output of the calculated volume and surface area of every Cylinder object into a file called "cylinders.txt". The sample output of the file is given below. Sample output Enter the radius for Cylinder 1 : 2 Enter the height for Cylinder 1 : 4 Enter the radius for Cylinder 2 : 7 Enter the height for Cylinder 2 : 2 Enter the radius for Cylinder 3 : 8.1 Enter the height for Cylinder 3 : 5.43 Program ended with exit code: 0arrow_forwardNOTE: The Array, ArrayList or List class may not be used Write a program that will create an invoice for a customer order based on their requests. Your program should prompt the user for their requested items based on a stock number then store the associated information in an array to be displayed in the invoice. 1. Define a Java class as described below. All variables should be declared as private and all methods as public. Save the class definition in a file with an appropriate filename. Class Name: Inventory Instance Variables: itemName - String price - double quantity - integer Instance Methods: A default constructor A constructor that accepts three arguments, one for each of the fields. getter methods for each of the class fields. toString() A method to display the fields of an instance of the class in to be displayed on the order sheet. Compile and debug the above code. 1. Then, create a class, TestInventory that contains a main() with static methods to create an invoice using…arrow_forwardWrite the program in C++arrow_forward
- EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:Cengage