
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
thumb_up100%

Transcribed Image Text:Upload Documents for Free Acce X
Announcements - IT-140-J6182
zy Section 8.6 - IT 140: Introduction X
Answered: ting Write a program X
https://learn.zybooks.com/zybook/SNHUIT140V3/chapter/8/section/6
= zyBooks My library > IT 140: Introduction to Scripting v3 home > 8.6: Class constructors
E zyBooks catalog
? Help/FAQ 8 Jose Roque
Write a constructor with parameters self, num_mins and num_messages. num_mins and num_messages should have a default
value of 0.
Sample output with one plan created with input: 200 300, one plan created with no input, and one plan created with input: 500
My plan... Mins: 200 Messages: 300
Dad's plan... Mins: 0 Messages: 0
Mom's plan... Mins: 500 Messages: 0
247772.2002516.qx3zqy7
1 class PhonePlan:
2
# FIXME add constructor
1 test
3
passed
4
'' Your solution goes here '''
All tests
def print_plan(self):
print('Mins:', self.num_mins, end=' ')
print('Messages:', self.num_messages)
6.
passed
7
8
9.
10
11 my_plan = PhonePlan(int(input()), int(input()))
12 dads_plan = PhonePlan()
13 moms_plan = PhonePlan(int(input()))
14
15 print('My plan...', end=' ')
16 my_plan.print_plan()
17
18 print('Dad\'s plan...', end=' ')
10 dads nlan nrint nlan/)
2:11 PM
O Type here to search
(D ツ
8/16/2021
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 4 steps with 2 images

Knowledge Booster
Similar questions
- In main.py define the Student class that has two attributes: name and gpa Implement the following instance methods: • A constructor that sets name to "Louie" and gpa to 1.0 set_name(self, name) - set student's name to parameter name get_name(self) - return student's name set_gpa(self, gpa) - set student's gpa to parameter gpa get_gpa(self) - return student's gpa Ex. If a new Student object is created, the default output is: Louie/1.0 Ex. If the student's name is set to "Felix" and the gpa is set to 3.7, the output becomes: Felix/3.7arrow_forwardA class called Location. A Location will have two attributes: city state A Location will have these methods: default constructor overloaded constructor copy constructor setters and getters for all attributes get State initials – get the abbreviation for the state. You may use a utility or a case structure. (FYI, you don’t have to put all 50 states in, at least have what you have in the file. Pick a few and test. equals() toString() An EntertainmentPlace class. An EntertainmentPlace will have these attributes: name type (Example house, amusement park, corn maze, escape room) price Location - this will be of the Location location (feel free to change the reference name) An EntertainmentPlace will have these methods: default constructor overloaded constructor that allows name, type, price and a Location object to be passed in overloaded constructor that allows name, price Location copy constructor all getters all setters equals() copy() method toString() - this will include…arrow_forwardThe goal of this coding exercise is to create two classes BookstoreBook and LibraryBook. Both classes have these attributes: author: Stringtiltle: Stringisbn : String- The BookstoreBook has an additional data member to store the price of the book, and whether the book is on sale or not. If a bookstore book is on sale, we need to add the reduction percentage (like 20% off...etc). For a LibraryBook, we add the call number (that tells you where the book is in the library) as a string. The call number is automatically generated by the following procedure:The call number is a string with the format xx.yyy.c, where xx is the floor number that is randomly assigned (our library has 99 floors), yyy are the first three letters of the author’s name (we assume that all names are at least three letters long), and c is the last character of the isbn.- In each of the classes, add the setters, the getters, at least three constructors (of your choosing) and override the toString method (see samplerun…arrow_forward
- Write a second constructor as indicated. Sample output: User1: Minutes: 0, Messages: 0 User2: Minutes: 1000, Messages: 5000 // ===== Code from file PhonePlan.java =====public class PhonePlan {private int freeMinutes;private int freeMessages; public PhonePlan() {freeMinutes = 0;freeMessages = 0;} // FIXME: Create a second constructor with numMinutes and numMessages parameters. /* Your solution goes here */ public void print() {System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages);}}// ===== end ===== // ===== Code from file CallPhonePlan.java =====public class CallPhonePlan {public static void main(String [] args) {PhonePlan user1Plan = new PhonePlan(); // Calls default constructorPhonePlan user2Plan = new PhonePlan(1000, 5000); // Calls newly-created constructor System.out.print("User1: ");user1Plan.print(); System.out.print("User2: ");user2Plan.print();}}// ===== end =====arrow_forwardThis project has 3 classes which are already defined for you. Do not change any of these: Vehicle: an abstract class for any make and model of vehicle that can possibly travel some distance. LimitedRange: an interface for something that has a limit to the distance it can travel. Main: a test program which will work after you have written the code below. Your job is to write the following 3 classes so that this program produces the sample output shown at the end of Main. Specifically you will need: ElectricCar: a vehicle with a limited range. So it must be a subclass of Vehicle, and it must implement LimitedRange. Thus it needs an instance variable for its range, and a travel method (required by Vehicle. Please use @Override) that outputs "Zoom!" if it has enough range to go the distance specified (and update its range). It must have a constructor with 3 arguments as called by main. (Remember that the first line of the constructor must be a call to "super": Vehicle's constructor…arrow_forwardWrite a second constructor as indicated. Sample output:User1: Minutes: 0, Messages: 0 User2: Minutes: 1000, Messages: 5000 // ===== Code from file PhonePlan.java =====public class PhonePlan { private int freeMinutes; private int freeMessages; public PhonePlan() { freeMinutes = 0; freeMessages = 0; } // FIXME: Create a second constructor with numMinutes and numMessages parameters. /* Your solution goes here */ public void print() { System.out.println("Minutes: " + freeMinutes + ", Messages: " + freeMessages); }}// ===== end ===== // ===== Code from file CallPhonePlan.java =====public class CallPhonePlan { public static void main(String [] args) { PhonePlan user1Plan = new PhonePlan(); // Calls default constructor PhonePlan user2Plan = new PhonePlan(1000, 5000); // Calls newly-created constructor System.out.print("User1: "); user1Plan.print(); System.out.print("User2: "); user2Plan.print(); }}// ===== end =====arrow_forward
- It not complex please don't reject it. give code of it. Wrong answer downvote surearrow_forwardIn c++ Create a new project named lab7_2. You’re going to write a class of your choice! The class should contain: A default constructor and a constructor with parameters for all your member variables. Setters and getters for all member variables. A method that prints out information about your class’s member variables. Your class should again try to minimize the number of methods that modify private member variables. Don’t repeat code! You will create an object of your class type in the driver file. I would like you to create this object on the heap! So your declaration for it should look like: SomeClass* someClassPtr = new SomeClass; Now, you will have to remember that before you can access methods, you need to dereference the pointer to your object. You will recall that using the arrow operator (->) facilitates this kind of access. someClassPtr->someMethod(); At the end of your program, don’t forget to delete your pointer: delete someClassPtr;arrow_forwardThe Essay class has a default constructor, a constructor with two parameters, and a constructor with three parameters. Declare the following objects: essay1 with no arguments essay2 with essayTitle and essayAuthor as arguments essay3 with essayTitle, essayAuthor, and essayYear as arguments Ex: If the input is Painting Cole 1919, then the output is: Essay: Undefined, Unspecified, 0 Essay: Painting, Cole, 0 Essay: Painting, Cole, 1919 Archive.java public class Archive { publicstaticvoidmain(String[] args) { Scannerscnr=newScanner(System.in); StringessayTitle; StringessayAuthor; intessayYear; essayTitle=scnr.next(); essayAuthor=scnr.next(); essayYear=scnr.nextInt(); /* Your code goes here */ essay1.print(); essay2.print(); essay3.print(); } } Essay.java public class Essay { private String title; private String author; private int year; public Essay() { // Default constructor title = "Undefined"; author = "Unspecified"; year = 0; }…arrow_forward
- Complete the FoodItem class by adding a constructor to initialize a food item. The constructor should initialize the name to "None" and all other instance attributes to 0.0 by default. If the constructor is called with a food name, grams of fat, grams of carbohydrates, and grams of protein, the constructor should assign each instance attribute with the appropriate parameter value. The given program accepts as input a food item name, fat, carbs, and protein and the number of servings. The program creates a food item using the constructor parameters' default values and a food item using the input values. The program outputs the nutritional information and calories per serving for both food items. Ex: If the input is: M&M's 10.0 34.0 2.0 1.0 where M&M's is the food name, 10.0 is the grams of fat, 34.0 is the grams of carbohydrates, 2.0 is the grams of protein, and 1.0 is the number of servings, the output is: Nutritional information per serving of None: Fat: 0.00 g Carbohydrates:…arrow_forwardC++ Programming. Create a "Stool' class. Fields: height (h, cm), product quality (low, medium, high). Specify two virtual methods: The "Wood amount" method determines the amount of wood that goes into the stool: 4 • h + 12 if the product quality is low, 5 • h + 14 if the quality is average or high. "Price" method is equal to d • 2 for low quality, d • 3 for medium quality, d • 4 for high quality, where d is the amount of wood required for the object. Also write an "Information" method that prints information about the object: Height, Material Quality, Wood Quantity, and Price. Also create an inheritance class "Chair". Additional area: back height (h2, cm). In the reloaded "Amount of Wood" method, the amount of wood is calculated using the formula d + 2 • h2 + 5.arrow_forwardThe total cost of a group of items at a grocery store is based on the sum of the individual product prices and the tax (which is 5.75%). Products that are considered “necessities” are not taxed, whereas products that are considered “luxuries” are. The Product class is abstract, and it has a method called getTotalPrice. Your task is to create two subclasses of Product: NecessaryProduct and LuxuryProduct and implement the getTotalPrice method in each of these classes appropriately. Then modify the driver program to instantiate four products (two necessary and two luxury) and store them in the product array, print out each item in the array, and display the total cost of the items. You should not make any changes at all to Product.java, and you should only add to ShoppingTripStartingCode.java. Do not change any code that is already present Example(Cheese and bread are necessities and soda and candy are luxuries)Cheese…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY

Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON

Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education

Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY