Computer Networking: A Top-Down Approach (7th Edition)
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
Bartleby Related Questions Icon
Related questions
Question
Need help with writing the program creating two different class files (Instruction are attatched in the images). Please provide with ss of your code if possible.
Transcribed Image Text:### Class Design for Cylinder Representation
In this exercise, we will design a class named `Cylinder` to represent cylinders.
#### Class Specifications
The `Cylinder` class will contain the following features:
- **Private Data Fields:**
- `radius`: A double that specifies the radius of a cylinder with a default value of 1.0.
- `length`: A double that specifies the length of a cylinder with a default value of 1.0.
- `numberOfObjects`: An integer static data field that tracks the number of cylinder objects created. The default value is `0`.
- **Constructors:**
- A no-argument constructor that creates a cylinder with default values.
- A constructor with parameters that accepts specified values for radius and length.
- **Methods:**
- Get and set methods for the `radius` and `length` fields.
- `getArea()`: A method that returns the base area of the cylinder.
- `getVolume()`: A method that returns the volume of the cylinder.
- `getNumberOfObjects()`: A static method that returns the value of the `numberOfObjects` field.
#### Requirements
1. **UML Diagram and Implementation:**
- Draw the UML (Unified Modeling Language) diagram for the `Cylinder` class.
- Implement the class ensuring that data fields are private, with constructors and other methods set to public.
2. **Test Program:**
- Write a test program that performs the following tasks:
- Create the first cylinder object using the no-argument constructor.
- Create a second cylinder object using the constructor with parameters (setting radius to 2.5 and length to 12.3).
- Create a third cylinder object using the no-argument constructor.
- Modify the third cylinder’s radius to 5.0 and length to 6.5.
- Print the radius and length of the first cylinder.
- Print the area of the second cylinder.
- Print the volume of the third cylinder.
- Print the value of the `numberOfObjects` data field.
### Detailed Steps
#### Step 1: UML Diagram
Create a UML diagram which should visually represent the class with its data fields and methods, specifying their visibility (private or public).
#### Step 2: Cylinder Class Implementation
Write the implementation code for the `Cylinder` class based on the above-mentioned specifications.
Transcribed Image Text:### Cylinder Properties and Objects
The following information provides details about three different cylindrical objects:
1. **First Cylinder:**
- **Radius:** 1.0 units
- **Length:** 1.0 units
2. **Second Cylinder:**
- **Base Area:** 19.634954084936208 square units
3. **Third Cylinder:**
- **Volume:** 510.5088062083414 cubic units
In summary, a total of **3 objects** have been created with the specified properties.
Expert Solution
Check MarkThis question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
bartleby
Step by stepSolved in 6 steps with 3 images
Knowledge Booster
Background pattern image
Similar questions
- It's not apparent what will happen if an incorrectly coded software is executed. What will happen after the frmProgram code has been written? Is it possible to display the event handler for the command button? The sentence "Unload Me" has a function, but what is it? What does an executable file do?arrow_forwardFor this task, you are to write code that handles the transfer of virtual coins between players in a video game. Instructions As this task relates to tranferring coins between players, a Player class has been provided, which supports adding and subtracting coins. Also provided is an interactive loop for testing the transfer of coins between players. Part A You are to write a function called transfer_coins with three parameters: the number of coins to transfer, the player from which coins will be taken (the "giver"), and the player which the coins will be given to (the "receiver"). It should use the appropriate instance methods on each of the player objects to update them as required. Part B If you tested your solution thoroughly in the previous part, you probably came across a logic error in the program---there's nothing to stop us from taking more coins from a player than they have! You are to fix this problem by raising an exception instead of completing the...arrow_forwardThis is a one question problem with multiple parts (part (a) to (e), please help with every part. Use matlab for the code. Goal: The intent of this problem is to have you visualize electric fields and understand spatial relationships between charge distributions and E. Instructions: Combine all parts of the problem into a single file and upload either a .pdf or image file of all parts of the question. 1. Develop a code that can plot the electric field produced by two point charges separated by a distance d where the origin is in the middle of the two charges. You may use whatever language is most convenient for you. (a) Produce a plot of the electric field produced by a dipole (equal and opposite point charges) (b) Produce a plot of the electric field of two identical point charges (c) Produce a plot of two charges with random charge values (keep them reasonably close in magnitude) (d) Discuss the electric field distributions for the three cases above. Take note of where the...arrow_forward
- If fopen cannot open the file (filename mistyped, file does not exist in the current directory (folder), or we have no permission to open the file, etc) then a.We know that there is a problem because the next fprintf fails b.fopen issues a standard matlab error explaining the problem c.The file will always be created if it does not exist and fopen always opens a file. It is the responsibility of the programmer to make sure that the file is indeed what he intended d. fopen returns -1 and we know there is a problem and fix itarrow_forwardin python, implant class for worker attributes name and phone .in other file import worker , get input for attribute, append , in def print open and save information in file .txtarrow_forwardHey, I need assistance with this question; The main reason I can't do it is I don't really understand the malloc, realloc and the whole resizing arrays and how to adapt that to my code. If you could assist me with the changes below that would be really helpful. Modify your program from stage 2 so that it reads the input file (parameter 1), storing all the records into a dynamic array in memory. The program should then sort the data records and write the output file (parameter 2) in sorted order. The automarker will test your program by running it many times, each time with a different input file name and an output file name, and it will then compare your output file with the expected output file. Use the Linux library sort routine qsort to perform the sorting. Hint: you must write a comparison routine that can compare two structures according to the sort order specified for your lab. Your program will need to store all the records in memory in order to sort them. The program will...arrow_forward
- Given the following code, I need help correcting it to follow these instructions using python (the csv file contains the following info...) Jan 14317 Feb 3903 Mar 1073 Apr 3463 May 2429 Jun 4324 Jul 9762 Aug 15578 Sep 2437 Oct 6735 Nov 88 Dec 2497 #import the csv module for read-writeimport csv #file name for csvFILE_NAME = "monthly_sales.csv" #Show title of editordef display_title(): print("FirstName LastName's Monthly Sales") #space print() #show user menu displaydef display_menu(): print("Command Menu\n\n Monthly - View monthly sales\n yearly - View yearly summary\n edit - Edit sales for a month\n exit - Exit program") """def read_sales():""" #main functiondef main(): sales = [] #write to the csv file with open(FILE_NAME, "r", newline="") as file: reader = csv.reader(file) for row in reader: sales.append(row) #print out the display title and menu and then give user options to choose from...arrow_forwardI need a code that displays a program that is subject to variable attack (buffer overflow). Can be any languaje. Please explain the codearrow_forwardThe code I am running is producing overlap and not sure how to get the correct format. I have most of it when testing it it contains the other stuff I was testing and I'm not sure if there is a way to capture what I enter than the previous unless that is by default. I am providing my code and need assistance. #Enter the name of the file to append [diary.txt]file_name = input("Enter the name of the file you want to append to: ")print() #Enter the user sentenceuser_sentence = input("Please enter a sentence: ")print() #Append file and write user_sentencewith open(file_name, 'a') as file: file.write(user_sentence + "\n")#Read the file and print contents of the filewith open(file_name, 'r') as file: file_contents = file.read() print('The contents of', file_name, 'is now:','\n') print(file_contents) Thank you for your assistance !arrow_forward
arrow_back_ios
arrow_forward_ios
Recommended textbooks for you
- Text book imageComputer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONText book imageComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceText book imageNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Text book imageConcepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningText book imagePrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationText book imageSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY
Text book image
Computer Networking: A Top-Down Approach (7th Edi...
Computer Engineering
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:PEARSON
Text book image
Computer Organization and Design MIPS Edition, Fi...
Computer Engineering
ISBN:9780124077263
Author:David A. Patterson, John L. Hennessy
Publisher:Elsevier Science
Text book image
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:9781337569330
Author:Jill West, Tamara Dean, Jean Andrews
Publisher:Cengage Learning
Text book image
Concepts of Database Management
Computer Engineering
ISBN:9781337093422
Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:Cengage Learning
Text book image
Prelude to Programming
Computer Engineering
ISBN:9780133750423
Author:VENIT, Stewart
Publisher:Pearson Education
Text book image
Sc Business Data Communications and Networking, T...
Computer Engineering
ISBN:9781119368830
Author:FITZGERALD
Publisher:WILEY