
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

Transcribed Image Text:NL Can is a local can-making company that makes cans using an eco-friendly materlal. Recently a number of
new eco-friendly palnt companles have started up In the area and they have been placing large orders for
materlal used for the quantity of cans ordered, and the total cost of the order with appropriate descriptive
labels, as shown In the sample output
palnt cans In whlch to put their eco-friendly palnt. NL Can has asked you to design, Implement and test a
Python class, CanOrder, to generate order objects for cans with the following attributes (Instance varlables)
Also Include a main function to test the defined class as follows:
and class varlables.
• create 2 CanOrder objects
• print Information about each order using the special stz ) method
• change the helght of the can In the second order and print the order ID, the updated helght and the
Class variables:
• NoOfOrders Is a class varlable that keeps track of the number of orders created (Initially O):
NoOFOrders automatically Increments with each new object created, I.e., when the first object Is
created, NoO£Orders should become 1, when the second object is created, No0FOrders should
updated total cost of the order with approprlate descriptive labels
• print the total number of orders with an approprlate descriptive label
change to 2, etc.
• NextOrderNo is a class varlable, Initlalized to 100, which Is used to generate the orderiD number for
each order as a sequence of even numbers, starting with 100; I.e., the first order would have an orderiD of
100, the second order created would have an orderID of 102, etc.
Instance variables:
• orderID Is a unique number Identifylng the can order and Is set using the NextOrderNo class varlable
• quantityOrdered is the number of cans ordered (default value 0)
• rzdius is the radlus of the can In Inches (default value 0.0)
• height Is the height of the can In Inches (default value 0.0)
• handle isa True/False value Indicating If the cans In the order should have a handle (True) or not (False)
(default value False)
• print the total cost of all the orders (both orders, Including the effect of the changed helght of the second
order), with an approprlate descriptive label
Call the file contalning your class and main function, nl_cans.py.
Sample Input/output:
Order ID: 100
Also include the following methods:
a constructor method for the CanOrder class with default values for all 4 parameters (not Including the
self parameter)
• three accessor methods, one to retrieve the ID of the order, one for the radlus, and one for the helght
• two mutator methods, one to change the radlus of the can, and one to change the helght of the can
• a method called getTotalsurfacekrea to compute and return the total surface area of all cans
ordered; the formula for the surface area of a can Is: 2ar- 2arh (note: use the math library to get the
constant varlable pi and the pow function)
• a method called getTotal1cost to compute and return the total cost of the order, where the cost of the
materlal used Is half of a cent (So.005) per square centimetre of surface area and If handles are required,
then an extra fifty cents ($0.50) Is added for each can
• the speclalstr_() method to print the Information about the order Including the orderiD, the radlus
and the helght of the can, the quantity ordered, the handle optlon (True/False), the total surface area of
Can Radius: 5 cm
Can Height: 10 cm
Quantity Ordered: 100 cans
Handle Needed? False
Total Surface Area: 47123.89 =q. cm.
Total Cost: $235.62
Order ID: 102
Can Radius: 7.5 cm
Can Height: 20 cm
Quantity Ordered: 300 cans
Handle Needed? True
Total Surface Area: 388772.09 g.cm.
Total Cost: $2093.86
materlal used for the quantity of cans ordered, and the total cost of the order with appropriate descriptive
1- ... ta al.-..---.
The height of cans for Order ID 102 has been changed to 21.00.
The new cost of for Order ID 102 is $2164.55.
--
The total number of orders received was 2.
O Download
A Print
>
The tota1 cost of all orders received was $2400.17.
Expert Solution

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

Knowledge Booster
Similar questions
- This is in C++ given main(), define the Team class (in files Team.h and Team.cpp). For class member function GetWinPercentage(), the formula is: teamWins / (teamWins + teamLosses) Use casting to prevent integer division. Ex: If the input is: Ravens 13 3 where Ravens is the team's name, 13 is number of team wins, and 3 is the number of team losses, the output is: Congratulations! Team Ravens has a winning average! If the input is Angels 80 82, the output is: Team Angels has a losing average. The template provided is this: #include <iostream>#include <string>#include "Team.h"using namespace std; int main(int argc, const char* argv[]) {string name;int wins;int losses;Team team; cin >> name;cin >> wins;cin >> losses; team.SetTeamName(name);team.SetTeamWins(wins);team.SetTeamLosses(losses); if (team.GetWinPercentage() >= 0.5) {cout << "Congratulations, Team " << team.GetTeamName() <<" has a winning average!" << endl;}else {cout…arrow_forwardIn Python IDLE: How would I write code for the two problems in the attached image?arrow_forwardaccessor methods for each of the instance variables A local taxi company has decided to expand and not only have taxis that go on land (i.e., cars), but also taxis that go on water (i.e., boats). You have been asked to design a number of classes to represent the various taxi fares (trips with passengers) and their various fee structures, by using inheritance in Python. a computeCharges method that returns the total charges for the cab fare, using the instance variables and the defined constants (i.e., kms multiplied by the cost per km, plus minutes multiplied by the cost per minute) Please read all parts of this question below before starting the question. Include the completed code for all parts of this question in a file called taxi_company.py- NOTE: To implement encapsulation, all of the instance variables/fields should be considered private. Question 3 (a) Design and implement a class called TaxiFare that includes the following instance variable(s) and method(s) for an object.…arrow_forward
- Hello, I am having trouble with this question for my c++ homework. How would I go about having it be declared as a class rather than writing it as #include <iostream> using namespace std: //# define N 8 I want to implement it as a class so I tried the following class: qColumns (N=8){} I'm stuck here N-Queens.A Queen on a chessboard can attack any piece in the same column, row or diagonal.The N-Queens problem is to place n queens on a n x n chessboard such that no twoqueens threaten each other.a) Implement a one-dimensional integer array of Queen positions for an 8x8 boardwhere indices represent rows and the values represent columns.For example, this “safe” solution would be {3,6,2,7,1,4,0,5}. . . Q . . . .. . . . . . Q .. . Q . . . . .. . . . . . . Q. Q . . . . . .. . . . Q . . .Q . . . . . . .. . . . . Q . .b) Request values for the array from the console.c) Implement an output to display the board (see output example).d) Implement a queensAreSafe function that:1) Returns…arrow_forwarderror on python code: File "/root/sandbox/MyMotorcycleClassProgram.py", line 11, in <module> motorcycleOne = Motorcycle(90.0)TypeError: Motorcycle.__init__() takes 1 positional argument but 2 were given from Vehicle import Vehicle # Write the Motorcycle class here class Motorcycle(Vehicle): def__init__(self): Vehicle.__init__(self) self._sidecar = sidecar defset_sidecar(self,sC): self._sidecar = sidecar defget_sidecar(self): returnself._sidecar defaccelerate(self,mph): ifself._speed + mph >self._max_speed: self._speed =self._speed + mph else: print("This motorcycle cannot go that fast.")arrow_forwardPlease answer question. This is pertaining to Java programming language 3-20arrow_forward
- Use as many advanced python techniques as you can • Write classes to support the Decrypt and the Rotation algorithms.• Use Bitsets, Bytes, where bit manipulations are needed.• Use Regular Expressions to parse and search strings.• Write any supporting classes necessary to support the Decrypt and Rotation Algorithms.• For example, the Decrypt Algorithm needs support for reading an encrypted file.• The Decrypt class is only responsible for decrypting a character, NOT reading a file ANDdecrypting each character.arrow_forwardCreate a python class that holds the following personal data: name, address, age, and phone number. Be sure to include proper accessor and mutuator methods. There should be modifier class that creates three instances of the class described. One instance should hold the information, and the other two should hold the information of friends/family members. This problem has been giving me a lot of trouble. Any help is greatly appreciated. Thanks so much!!arrow_forwardPLease help with the following: Consider the following Python code: class A:def f(self): passclass B(A):def f(self): passclass C(A):def f(self): passclass D(B, C): pass Which of the following is correct? a. The above code does not compile. It is an example of diamond problem.b. Class D has ambiguous MRO and therefore is not instantiable.c. The program has compiler error.d. The above code does not compile because Python does not support muliple inheritance.e. The above code compiles and runs with no issue.arrow_forward
- Please write in your own original code. Example output is attached Objective Create a class hierarchy by defining an abstract Shape class and concrete classes pertaining to various shapes: Circle, Sphere, Cylinder, Square, Cube, Triangle and Tetrahedron. Related SLO Develop properly structured multifile programs with automatic compilation. Use classes, polymorphism and inheritance in C++. Instructions Download the following starter file: https://laulima.hawaii.edu/x/6rw8eB Right-click on the link above > Save link as Rename LastnameFirstname22.cpp so that Lastname is your own last name and Firstname is your own first name. Create a makefile named makefile that will automatically compile, link, and create an executable for this assignment. IMPORTANT: Be sure to use g++ as the compiler NOT gcc as we are now programming in C++. Example makefile using g++ here There are no extra .h or .cpp needed for this assignment. Do NOT submit a makefile with any other name. The…arrow_forwardin python language In this task, we’re going to be simulating an email message. Some of the logic hasbeen filled out for you in the email.py file.● Open the file called email.py.● Create a class definition for an Email which has four variables:has_been_read, email_contents, is_spam and from_address.● The constructor should initialise the sender’s email address.● The constructor should also initialise has_been_read and is_spam to false.● Create a function in this class called mark_as_read which should changehas_been_read to true.● Create a function in this class called mark_as_spam which should changeis_spam to true.● Create a list called inbox to store all emails (note that you can have a list ofobjects).● Then create the following methods:○ add_email - which takes in the contents and email address from thereceived email to make a new Email object.○ get_count - returns the number of messages in the store.○ get_email - returns the contents of an email in the list. For this, allowthe…arrow_forwardIn Python without using super(): Given the base class Book, define a derived class called Encyclopedia. Within the derived Encyclopedia class, define a print_info() method that overrides the Book class' print_info() method by printing not only the title, author, publisher, and publication date, but also the edition and number of volumes. Ex: If the input is: The Hobbit J. R. R. Tolkien George Allen & Unwin 21 September 1937 The Illustrated Encyclopedia of the Universe James W. Guthrie Watson-Guptill 2001 2nd 1 the output is: Book Information: Book Title: The Hobbit Author: J. R. R. Tolkien Publisher: George Allen & Unwin Publication Date: 21 September 1937 Book Information: Book Title: The Illustrated Encyclopedia of the Universe Author: James W. Guthrie Publisher: Watson-Guptill Publication Date: 2001 Edition: 2nd Number of Volumes: 1 Default code: class Book: def __init__(self, title, author, publisher, publication_date): self.title = title self.author =…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