Suppose sam is an object of a class named Person and suppose increaseAge is a method for the class Person that takes one argument that is an integer. How do you write an invocation of the method increaseAge using sam as the calling object and using the argument 10? The method increaseAge will change the data in sam so that it simulates sam aging by 10 years.
Want to see the full answer?
Check out a sample textbook solutionChapter 1 Solutions
Absolute Java (6th Edition)
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Concepts Of Programming Languages
Mechanics of Materials (10th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
Degarmo's Materials And Processes In Manufacturing
- The local Driver’s License Office has asked you to write a program that grades the written portion of the driver’s license exam. The exam has 10 multiple-choice questions. Here are the correct answers: 1. B 2. D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D A student must correctly answer 7 of the 10 questions to pass the exam. Write a class named DriverExam that holds the correct answers to the exam in an array field. The class should also have an array field that holds the student’s answers. The class should have the following methods: • passed. Returns true if the student passed the exam, or false if the student failed. • totalCorrect. Returns the total number of correctly answered questions. • totalIncorrect. Returns the total number of incorrectly answered questions. • questionsMissed. An int array containing the question numbers of the questions that the student missed, i.e. answered incorrectly. Test the class in a separate class, DriverTest , that asks the user to enter a student’s…arrow_forwardPLEASE USE PYTHON PROGRAMMING Create a class called Numbers, which has a single class attribute called MULTIPLIER, and a constructor which takes the parameters x and y (these should all be numbers). Write a method called add which returns the sum of the attributes x and y. Write a class method called multiply, which takes a single number parameter aand returns the product of a and MULTIPLIER. Write a static method called subtract, which takes two number parameters, b and c, and returns b - c. Write a method called value which returns a tuple containing the values of x and y. Make this method into a property, and write a setter and a deleter for manipulating the values of x and y. class Numbers: # TODO: create a class attribute called MULTIPLIER def __init__(self, x, y): self.x = x self.y = y def add(self): # TODO: return x + y def multiply(self, a): # TODO: return the attribute MULTIPLIER * by a. @staticmethod def subtract(b, c):…arrow_forwardPlease include doctring, and write only in python: First, write a class named Movie that has four data members: title, genre, director, and year. It should have: an init method that takes as arguments the title, genre, director, and year (in that order) and assigns them to the data members. The year is an integer and the others are strings. get methods for each of the data members (get_title, get_genre, get_director, and get_year). Next write a class named StreamingService that has two data members: name and catalog. the catalog is a dictionary of Movies, with the titles as the keys and the Movie objects as the corresponding values (you can assume there aren't any Movies with the same title). The StreamingService class should have: an init method that takes the name as an argument, and assigns it to the name data member. The catalog data member should be initialized to an empty dictionary. get methods for each of the data members (get_name and get_catalog). a method named add_movie…arrow_forward
- Pythonarrow_forwardWrite a JAVA PROGRAM that a class has an integer data member "i" and a method named "printNum" to print the value of 'i'. Its subclass also has an integer data member 'j'and a method named 'printNum'to print the value of 'j'. Make an object of the subclass and use it to assign a value to 'i'and to 'j'. Now call the method 'printNum'by this object.arrow_forwardwrite a code in javaarrow_forward
- 1)The program should be written in JAVA. Create a "Car" class that keeps car ids and prices. And create a "Galleries" class that holds the car list for a particular gallery. In this class there should be methods for get / set and print for car name, car number and car list. Adding / Removing Cars to the List in This Class should have methods. And create another method to find and print the IDs of Cars with Car Segment equal to X. (print_id(X)). Car Prices are as follows according to the segments. 0$-19999$ -> Z20000$-29999$ -> Y30000$-44999$ -> T45000$-100000$ -> P Apply the Car list using "Singly Linked List"(Node, newNode, head).arrow_forwardGive source code and output alsoarrow_forwardWhat is the solution for this question ( using java language)arrow_forward
- Create a class MyTime which has the datamembers as follows: 1. hour: integer (1 to 12)2. minute: integer (0 to 59)3. second: integer (0 to 59)4. pm: bool variable. True means PM time and false means AM time. Implement a default constructor, a parameterized constructor and a copy constructor. Write set and get functions for all the four members of the class. Overload these operators: 1. Extraction operator >> : Prompt the user for hours, minutes, seconds and for am/pm and initialize the structure. Left operand istream object and right operand MyTime2. Assignment = : Assign the right object to the left object. Both operands are of type MyTime.3. Insertion << : Print the time in the format HH:MM SS PM. Left operand of type ostream and right operand of type MyTime. this in c++.arrow_forwardPython Code: Write a class called Person with a constructor that takes two arguments, name and age and the saves these as attributes Write a method in this called print_person that prints out this information the console Confirm that you did it properly by instantiating an object called p1 and calling the method on the object. Lastly, extend the constructor by adding functionality that checks the input name only contains letters (no numbers allowed).arrow_forward8. Write a class named Power Calculator that includes a main method coded to prompt entry of data on 10 people. For each, the user should enter their age (int) followed by their name (String). Calculate their power score, which is the product of the length of their name and their age. Store the information in arrays and print out all the data in the format: following Name: Audrey Age: 21 Power Score: 126 Finally, print out the name associated with the highest score.arrow_forward
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,EBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT