Reference no: EM132395731
CS 1321L: Programming and Problem
Solving I Lab
Exercise #1: Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods:
A private variable of type double named radius to represent the radius. Set to 1.
Constructor Methods:
C# & Java: Default Constructor with no arguments.
C# & Java: Constructor method that creates a circle with user-specified radius.
Method getRadius() that returns the radius.
Method setRadius() that sets the radius.
Method getArea() that returns the area.
Method getPerimeter() that returns the perimeter.
Method toString()to printout a meaningful description of the circle as follows:
The circle has radius X. Where X is the value of variable radius.
Now design and implement a test program to create a default circle object and test all class methods on the object. Print the object after each method call and use meaningful label for each method call as shown in the following sample run.
Sample run:
Print radius:
The radius is 1.
Print area:
The area is 3.14
Print perimeter:
The perimeter is 6.28
Set radius to 10 and print the object: The circle has radius 10.
Print area:
The area is 314.23
Print perimeter:
The perimeter is 62.81
Exercise #2: Design and implement class Radio to represent a radio object. The class defines the following attributes (variables) and methods:
Assume that the station and volume settings range from 1 to 10.
A private variable of type int named station to represent a station number. Set to 1.
A private variable of type int named volume to represent the volume setting. Set to 1.
A private variable of type boolean named on to represent the radio on or off. Set to false.
A non-argument constructor method to create a default radio.
Method getStation() that returns the station.
Method getVolume() that returns the volume.
Method turnOn() that turns the radio on.
Method turnOff() that turns the radio off.
Method stationUp() that increments the station by 1 only when the radio is on.
Method stationDown() that decrements the station by 1 only when the radio is on.
Method volumeUp() that increment the volume by 1 only when the radio is on.
Method volumeDown() that decrements the volume by 1 only when the radio is on.
Method toString()to printout a meaningful description of the radio as follows(if the radio is on):
The radio station is X and the volume level is Y. Where X and Y are the values of variables station and volume. If the radio is off, the message is: The radio is off.
Now design and implement a test program to create a default radio object and test all class methods on the object in random order. Print the object after each method call and use meaningful label for each method call as shown in the following sample run.
Sample run:
Turn radio on:
The radio station is 1 and the volume level is 1.
Turn volume up by 3:
The radio station is 1 and the volume level is 4.
Move station up by 5:
The radio station is 6 and the volume level is 4.
Turn volume down by 1:
The radio station is 6 and the volume level is 3.
Move station up by 3:
The radio station is 9 and the volume level is 3.
Turn radio off.
The radio is off.
Turn volume up by 2: The radio is off.
Turn station down by 2: The radio is off.
Attachment:- Programming and Problem.rar
How would identifying a mentoring project activities
: How would identifying a mentoring project's activities and processes (e.g., observing documenting, reflecting, analysis, application, feedback, goal-setting.
|
Create your strategic mentoring plan using given details
: The summative assignment is a compilation of the revised assignments from weeks one through six. Using the feedback, you receive from the instructor.
|
Discuss topic immigrant children and their families
: Topic: Immigrant children and their families, Papers are to be 10-12 pages (not counting title, abstract, or reference pages), must use APA format.
|
Prepare a data analysis report for PhD using SPSS AMOS
: Prepare a data analysis report for PhD using SPSS AMOS. The AIM of this research is to gather information on the relationship between Entrepreneurial.
|
Design and implement class circle to represent circle
: Design and implement class Circle to represent a circle object. The class defines the following attributes (variables) and methods
|
What are the business costs or risks of poof data quality
: What are the business costs or risks of poof data quality? Support your discussion with at least 3 references. What is data mining? Support your discussion.
|
Analysis of the relevant privacy risks of selected carbon
: Analysis of the relevant privacy risks of the selected Carbon Black products, a one-page executive summary for the Acme Dynamics Board and C-Suite.
|
What you think about all of the given strange incidents
: Your boss mentions that recently a number of employees have received calls from individuals who didn't identify themselves and asked a lot of questions about.
|
Early years learning framework
: Select one topic from each of the following groups and, in 500 words, explain how it applies to early childhood education as outlined in the Early Years
|