SlideShare uma empresa Scribd logo
1 de 65
About 6 C++ code questions
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
About 6 C++ code questions. The question 1 and question 2 are
just about write some comments and draw some box-and-arrow
diagram to show your understanding of the given codes and
outputs. We used CodeLite and Java in this term, so please make
sure your codes are worked well with them.
------------------------------------------
CIS 244 Have you ever experience some kind of a
virus
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Have you ever experience some kind of a virus (any kind) on PC
that have tons of pop up...Was it the problem or the process that
held you up?
and your computer couldn't function properly. Can you explain
details of what happened? was it frustrating?
Can you explain different ways and steps that you've adjusted or
enhanced your problem solving skills to become more efficient
and/or effective?
300 words or more would be great. thx
250 words or more is fine. thx
------------------------------------------
CIS 3443 Chapter 4 – Decisions and Conditions
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Chapter 4 – Decisions and Conditions
1. What is the general format of the statement used to code
decisions in an application?
2. What is a Boolean expression?
6. Why would it be useful to include the ToUpper method in a
comparison?
10. Define the term validation. When is it appropriate to do
validation?
12. When would it be appropriate to use a Case structure? Give
an example
------------------------------------------
CMIS 141 Homework 2
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Homework 2
Before attempting this project, be sure you have completed all of
the reading assignments, hands-on
labs, discussions, and assignments to date.
Design a Java class named Polygon that contains: A private int
data field named numSides that defines the number of sides of the
polygon. The default value should be 4.
A private double data field named sideLength that defines the
length of each side. The
default value should be 5.0.
A private double data field named xCoord that defines the x-
coordinate of the center of
the polygon. The default value should be 0.0.
A private double data field named yCoord that defines the y-
coordinate of the center of
the polygon. The default value should be 0.0.
A private double data field named apothem that defines the
apothem of the polygon.
The default value should 5.0.
A private double data filed named perimeter that defines the
perimeter of the polygon.
The default value should 20.0.
A no argument constructor that creates a Polygon using the
default number of sides,
default side length, default x- and y-coordinates, and the default
apothem.
A constructor that creates a Polygon using a specified number of
sides, side length, xand y-coordinates and the apothem
Getter and setter methods for all data fields
A getArea() method that returns a double value representing the
area of the polygon.
(Note the area of a regular Polgon can be calculated from ½ *
Apothem*Perimeter)
A toString() method that displays the number of sides, side
length, x-coordinate, ycoordinate and apothem values in String
format Be sure your code compiles. You should use the command
prompt and not a GUI for data entry and
display.
Write a Java test program, named TestPolygon, to create 5
different polygons representing the 5 test
cases you just created. When creating the five polygons, create
one using the no argument constructor.
For the remaining four, feel free to use any number of sides, side
length and x-, and y-coordinates and
apothem that are not equal to the default values and not equal to
each other. For each of the five
polygons, call all of the methods and display the results. For
example for a Polygon with 3 sides, side
length of 2.0 and x-coordinate and y-coordinates of 1.0, and
apothem of 1.0 the following test data may
result:
***Output***
toString(): (numsides=3, sideLength=2.0, xcoord=1.0,ycoord=1.0,
apothem=1.0)
getNumSides(): 3
getSideLength(): 2.0
getXCoord(): 1.0
getYCoord(): 1.0
getApothem():1.0
getPerimeter(): 6.0 1 getArea(): 3.0 Document your test cases in
the form of table with columns indicating the input values,
expected
output, actual output and if the test case passed or failed. This
table should contain 4 columns with
appropriate labels and a row for each test case. An example
template is shown below. Note that the
actual output should be the actual results you receive when
running your program and applying the
input for the test record.
Keep in mind, for five Polygons, you will have five different
output results. Also, note there is no
requirement to actually draw a Polygon.
Example test cases:
Input
Constructor:
numsides=3
sideLength=2.0
xcoord=1.0
ycoord=1.0
apothem=1.0 Expected Output
** Output ** Actual Output
** Output ** toString(): (numsides=3,
sideLength=2.0,
xcoord=1.0,ycoord=1.0,
apothem=1.0)
getNumSides(): 3
getSideLength(): 2.0
getXCoord(): 1.0
getYCoord(): 1.0
getApothem():1.0
getPerimeter(): 6.0
getArea(): 3.0 toString(): (numsides=3,
sideLength=2.0,
xcoord=1.0,ycoord=1.0,
apothem=1.0)
getNumSides(): 3getSideLength(): 2.0
getXCoord(): 1.0
getYCoord(): 1.0
getApothem():1.0
getPerimeter(): 6.0
getArea(): 3.0 Pass?
Yes Test case 2 here
Test case 3 here
Test case 4 here
Test case 5 here The google recommended Java style guide,
provided as link in the week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. 2 Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
named appropriately for your applications. The word (or PDF)
document should include screen captures
showing the successful compiling and running of each of the test
cases. Each screen capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Homework 2 assignment area no later
than the due date listed in your LEO
classroom. You should include your name and HW2 in your word
(or PDF) file submitted (e.g.
firstnamelastnamehw2.docx or firstnamelastnamehw2.pdf)
Grading Rubric:
The following grading rubric will be used to determine your
grade:
Attribute
Polygon Class Meets
10 points Does not meet
0 points Private int data field named
numSides that defines the
number of sides of the polygon.
The default value should be 4. Private int data field named
numSides was not included. Private double data field named
sideLength that defines the
length of each side. The default
value should be 5.0.
Private double data field named
xCoord that defines the xcoordinate of the center of the
polygon. The default value
should be 0.0.
Private double data field named
yCoord that defines the ycoordinate of the center of the
polygon. The default value
should be 0.0.
Private double data field named
apothem that defines the
apothem of the polygon. The
default value should 5.0. Private double data field named
sideLength was not included
Private double data field named
xCoord was not included
Private double data field named
yCoord was not included
Private double data field named
apothem was not included.
Private double data filed named
perimeter was not included
No argument constructor that
creates a Polygon was not
included
Constructor that creates a
Polygon using a specified
number of sides, side length, xand y-coordinates and the
apothem was not included Private double data filed named
perimeter that defines the
3 perimeter of the polygon. The
default value should 20.0. Getter and setter methods for
all data fields were not included No argument constructor that
creates a Polygon using the
default number of sides, default
side length, default x- and ycoordinates, and the default
apothem. getArea() method was not
included Constructor that creates a
Polygon using a specified
number of sides, side length, xand y-coordinates and the
apothem toString() method was not
included
Command Line was not used for
running application Getter and setter methods for
all data fields
getArea() method that returns a
double value representing the
area of the polygon. (Note the
area of a regular Polgon can be
calculated from ½ *
Apothem*Perimeter)
toString() method that displays
the number of sides, side
length, x-coordinate, ycoordinate and apothem values
in String format Test Polygon Class Command line was used for
running the application.
5 points 0 points TestPolygon used to create 5
different polygons representing
the 5 test cases you just
created. TestPolygon was not used to
create 5 different polygons
representing the 5 test cases
you just created. One test cases used the no
argument constructor. One test cases was not used
with the no argument
constructor. An additional 4 test cases with
varying input values. 4 Test Cases For each of the five polygons,
all of the methods were called
and resulted displayed. An additional 4 test cases with
varying input values were not
used. Command Line was used for
output. For each of the five polygons,
none of the methods were
called 5 points
A minimum of 5 test cases was
used in the form of table with
columns indicating the input
values, expected output, actual
output and if the test case
passed or failed. The table
should contains 4 columns with
appropriate labels and a row for
each test case. Documentation and Style guide Test cases were
included in the
supporting word or PDF
documentation.
5 points
Screen captures were provided
and labeled for compiling your
code, and running each of your
5 test cases. Command Line was not used for
output.
0 points
No test cases were provided. 0 points
No documentation included
Java style guide was not used to
prepare the Java code. Header comments include
filename, author, date and brief
purpose of the program.
In-line comments used to
describe major functionality of
the code.
Meaningful variable names and
prompts applied.
Class names are written in
UpperCamelCase. 5 Variable names are written in
lowerCamelCase.
Constant names are in written
in All Capitals.
Braces use K&R style. 6
------------------------------------------
CMIS 141 Homework 3
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Homework 3
Before attempting this project, be sure you have completed all of
the reading assignments, hands-on
labs, discussions, and assignments to date.
Create a Java class named HeadPhone to represent a headphone
set. The class contains: Three constants named LOW, MEDIUM
and HIGH with values of 1, 2 and 3 to denote the
headphone volume.
A private int data field named volume that specifies the volume of
the headphone. The
default volume is MEDIUM.
A private boolean data field named pluggedIn that specifies if the
headphone is plugged
in. The default value is false.
A private String data field named manufacturer that specifies the
name of the
manufacturer of the headphones.
A private Color data field named headPhoneColor that specifies
the color of the
headphones.
A private String data field named headPhoneModel that specifies
the Model of the
headphones.
getter and setter methods for all data fields.
A no argument constructor that creates a default headphone.
A method named toString() that returns a string describing the
current field values of
the headphones.
A method named changeVolume(value) that changes the volume
of the headphone to
the value passed into the method Create a TestHeadPhone class
that constructs at least 3 HeadPhone objects. For each of the
objects
constructed, demonstrate the use of each of the methods. Be sure
to use your IDE to accomplish this
assignment.
The google recommended Java style guide, provided as link in the
week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
named appropriately for your applications. The word (or PDF)
document should include screen captures showing the successful
compiling and running of each of the test cases. Each screen
capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Homework 3 assignment area no later
than the due date listed in your LEO
classroom. You should include your name and HW3 in your word
(or PDF) file submitted (e.g.
firstnamelastnamehw3.docx or firstnamelastnamehw3.pdf)
Grading Rubric:
The following grading rubric will be used to determine your
grade:
Attribute
Headphone Class Meets
10 points Does not meet
0 points Three constants named LOW,
MEDIUM and HIGH with values
of 1, 2 and 3 to denote the
headphone volume Three constants named LOW,
MEDIUM and HIGH with values
of 1, 2 and 3 were not included. A private int data field named
volume that specifies the
volume of the headphone. The
default volume is MEDIUM.
A private boolean data field
named pluggedIn that specifies
if the headphone is plugged in.
The default value is false.
A private String data field
named manufacturer that
specifies the name of the
manufacturer of the
headphones. A private int data field named
volume was not included.
A private boolean data field
named pluggedIn was not
included.
A private String data field
named manufacturer was not
included
A private Color data field named
headPhoneColor was not
included. A private String data field
named headPhoneModel wasA private Color data field named
not included
headPhoneColor that specifies
the color of the headphones.
getter and setter methods for
all data fields were not
A private String data field
included.
named headPhoneModel that
specifies the Model of the
A no argument constructor was
headphones.
not included. getter and setter methods for
all data fields. A method named toString()was
not included. A no argument constructor that
creates a default headphone. A method named
changeVolume(value) was not
included. A method named toString() that
returns a string describing the
current field values of the
headphones. An IDE (Netbeans or Eclipse)
was not used for this
assignment. A method named
changeVolume(value) that
changes the volume of the
headphone to the value passed
into the method Test Headphone Class An IDE (Netbeans or
Eclipse)
was used for this assignment.
5 points 0 points TestHeadPhone class was used
to construct at least 3
HeadPhone objects. TestHeadPhone class was not
used to construct at least 3
HeadPhone objects. For each of the objects
constructed, the use of each of
the methods was demonstrated For each of the objects
constructed, the use of each of
the methods was not
demonstrated An IDE (Netbeans or Eclipse)
was used for this assignment. Test Cases 5 points
A minimum of 3 test cases was
used in the form of table with
columns indicating the input
values, expected output, actual
output and if the test case
passed or failed. The table
should contains 4 columns with
appropriate labels and a row for
each test case. An IDE (Netbeans or Eclipse)
was not used for this
assignment.
0 points
No test cases were provided. Documentation and Style guide Test
cases were included in the
supporting word or PDF
documentation.
5 points
Screen captures were provided
and labeled for compiling your
code, and running each of your
5 test cases.
Header comments include
filename, author, date and brief
purpose of the program.
In-line comments used to
describe major functionality of
the code.
Meaningful variable names and
prompts applied.
Class names are written in
UpperCamelCase.
Variable names are written in
lowerCamelCase.
Constant names are in written
in All Capitals.
Braces use K&R style. 0 points
No documentation included
Java style guide was not used to
prepare the Java code.
------------------------------------------
CMIS 141 Homework 4
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Homework 4
Before attempting this project, be sure you have completed all of
the reading assignments, hands-on
labs, discussions, and assignments to date.
Write a Java program the displays the State bird and flower. You
should use your IDE for this exercise.
You should also use Java classes to their full extent to include
multiple methods and at least two classes.
The program should prompt the user to enter a State and print
both the State bird and flower. The user
should be able to enter a State without worrying about case. (e.g.
Users could enter Maryland,
maryland, MARYLAND or any other possible combination of
lower and upper case characters. States
may also contain leading and trailing white spaces. Hint: Store
the State information in a multidimensional array. The program
should continue to prompt the user to enter a state until “None” is
entered. After all States have been entered by the user, the
program should display a summary of the
results. You will need to do some research to find the State birds
and flowers. Here is a sample run:
Enter a State or None to exit:
Maryland
Bird: Baltimore Oriole
Flower: Black-eyed Susan
Enter a State or None to exit:
Delaware
Bird: Blue Hen Chicken
Flower: Peach Blossom
Enter a State or None to exit:
None
**** Thank you *****
A summary report for each State, Bird, and Flower is:
Maryland, Baltimore Oriole, Black-eyed Susan
Delaware, Blue Hen Chicken, Peach Blossom
Please visit our site again! Create a test class that constructs at
least 3 States objects. For each of the objects constructed,
demonstrate the use of each of the methods. Be sure to use your
IDE to accomplish this assignment.
The google recommended Java style guide, provided as link in the
week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
named appropriately for your applications. The word (or PDF)
document should include screen captures
showing the successful compiling and running of each of the test
cases. Each screen capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Homework 4 assignment area no later
than the due date listed in your LEO
classroom. You should include your name and HW4 in your word
(or PDF) file submitted (e.g.
firstnamelastnamehw4.docx or firstnamelastnamehw4.pdf)
Grading Rubric:
The following grading rubric will be used to determine your
grade:
Attribute
StatesDataEntry Class Meets
10 points Does not meet
0 points The program prompts the user
to enter a State and prints both
the State bird and flower. The program does not prompt
the user to enter a State and
prints both the State bird and
flower. State data entry is case
insensitive.
States data may also contain
leading and trailing white
spaces.
The program continues to
prompt the user to enter a state
until “None” is entered.
After all data has been entered
by the user, the program
displays a summary report of all
------------------------------------------
CMIS 141 Project 4 This programming project
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Project 4
This programming project involves writing a program to manage
a student database. The interface to
the program should be a GUI that looks similar to the following:
A combo box should allow the user to select one of the four
database actions shown. The database
should be implemented as a HashMap, with the ID field as the key
and a student record consisting of a
name and major as the value. The operation should be performed
when the user clicks the Process
Request button. If the user attempts to insert a key that is already
in the database an error message
should be displayed using a JOptionPane message dialog box. If
the user attempts to delete, find or
update a record that is not in the database, a message should also
be displayed. After each successful
operation is completed a JOptionPane window should be
displayed confirming the success. In the case
of a successful Find request, a window should pop up containing
the student's ID, name, major and
current GPA. When the user selects the Update request, the
following JOptionPane windows should be
displayed to gather information about a course that has just been
completed: 1 This program must consist of two classes.
1. The first class should define the GUI and handle the database
interactions.
2. The second class named Student, should define the student
record. It must have instance
variables for the student name, major and two variables that are
used to compute the GPA. A
variable that contains the total number of credits completed and a
second variable that contains
the total quality points, which are the numeric value of the grade
received in a course times the
number of credit hours. It should not contain the student ID. The
class should have the following
three methods:
a. A constructor that is used when new student records are
created. It should accept the name
and major as parameters and initialize the fields that are used to
compute the GPA to zero.
b. The second method courseCompleted should accept the course
grade and credit hours and
update the variables used to compute the GPA. It will be called
when an Update request is
made.
c. The third method should override toString and return a labeled
string containing the
student name, major and GPA.
Finally when a student has not yet completed any course, the
GPA should be displayed as 4.0.
The google recommended Java style guide, provided as link in the
week 2 content, should be used to
format and document your code. Specifically, the following style
guide attributes should be addressed: Header comments include
filename, author, date and brief purpose of the program.
In-line comments used to describe major functionality of the code.
Meaningful variable names and prompts applied.
Class names are written in UpperCamelCase.
Variable names are written in lowerCamelCase.
Constant names are in written in All Capitals.
Braces use K&R style. In addition the following design
constraints should be followed: Declare all instance variables
private
Avoid the duplication of code
Also any exceptions thrown by nonnumeric inputs should be
properly handled Test cases should be supplied in the form of
table with columns indicating the input values, expected
output, actual output and if the test case passed or failed. This
table should contain 4 columns with
appropriate labels and a row for each test case. Note that the
actual output should be the actual results
you receive when running your program and applying the input
for the test record. Be sure to select
enough different scenarios to completely test the program.
Submission requirements
Deliverables include all Java files (.java) and a single word (or
PDF) document. The Java files should be
2 named appropriately for your applications. The word (or PDF)
document should include screen captures
showing the successful compiling and running of each of the test
cases. Each screen capture should be
properly labeled clearly indicated what the screen capture
represents. The test cases table should be
included in your word or PDF document and properly labeled as
well.
Submit your files to the Project 4 assignment area no later than
the due date listed in your LEO
classroom. You should include your name and P4 in your word
(or PDF) file submitted (e.g.
firstnamelastnameP4.docx or firstnamelastnameP4.pdf). Grading
Rubric:
The following grading rubric will be used to determine your
grade:
Attribute GUI Class Meets
40 points Does not meet
0 points Defines the GUI. Does not defines the GUI. Provides a
combo box to allow
the user to select one of the
four database actions including
insert, update, delete and find. Does not provide a combo box
to allow the user to select one
of the four database actions
including insert, update, delete
and find. The database is implemented as
a HashMap, with the ID field as
the key and a student record
consisting of a name and major
as the value.
The operation is performed
when the user clicks the Process
Request button.
If the user attempts to insert a
key that is already in the
database an error message is
displayed using a JOptionPane
message dialog box.
If the user attempts to delete,
find or update a record that is
not in the database, a message
is displayed. The database is not
implemented as a HashMap,
with the ID field as the key and
a student record consisting of a
name and major as the value.
The operation is not performed
when the user clicks the Process
Request button.
If the user attempts to insert a
key that is already in the
database an error message is
not displayed using a
JOptionPane message dialog
box.
If the user attempts to delete,
find or update a record that is 3 After each successful operation
is completed a JOptionPane
window is displayed confirming
the success.
In the case of a successful Find
request, a window pops-up
containing the student's ID,
name, major and current GPA.
When the user selects the
Update request, a JOptionPane
windows is displayed to gather
information about a course that
has just been completed
including the grade and number
of credits. Student class 40 points
Defines the student record.
Contains instance variables for
the student name, major and
two variables that are used to
compute the GPA.
Contains a variable
representing the total number
of credits completed
Contains a variable representing
the total quality points, which
are the numeric value of the
grade received in a course times
the number of credit hours.
The class should not should
contain the student ID. not in the database, a message
is not displayed.
After each successful operation
is completed a JOptionPane
window is not displayed
confirming the success.
In the case of a successful Find
request, a window does not
pop-up containing the student's
ID, name, major and current
GPA.
When the user selects the
Update request, a JOptionPane
window is not be displayed to
gather information about a
course that has just been
completed including the grade
and number of credits.
0 points
Does not define the student
record.
Does not contains instance
variables for the student name,
major and two variables that
are used to compute the GPA.
Does not contain a variable
representing the total number
of credits completed
Does not contain a variable
representing the total quality
points, which are the numeric
value of the grade received in a
course times the number of
credit hours.
The class contains the student
ID. Contains a constructor that is
used when new student records
are created. It should accept the Does not contains a constructor
name and major as parameters that is used when new student
4 and initialize the fields that are
used to compute the GPA to
zero.
Contains a method
courseCompleted that accepts
the course grade and credit
hours and update the variables
used to compute the GPA.
courseComplete is called when
an Update request is made.
Contains an overridden toString
method that returns a labeled
string containing the student
name, major and GPA. Test Cases records are created. It should
accept the name and major as
parameters and initialize the
fields that are used to compute
the GPA to zero.
Does not contains a method
courseCompleted that accepts
the course grade and credit
hours and update the variables
used to compute the GPA.
courseComplete is not called
when an Update request is
made. Calculates and displays a GPA of
4.0 for students who have not
yet completed any course. Does not contains an
overridden toString method
that returns a labeled string
containing the student name,
major and GPA. 10 points Does not calculate or display a
GPA of 4.0 for students who
have not yet completed any
course.
0 points Test cases are supplied in the
form of table with columns
indicating the input values,
expected output, actual output
and if the test case passed or
failed. No test cases were provided. Enough scenarios selected to
completely test the program. Documentation and Style guide Test
cases were included in the
supporting word or PDF
documentation.
10 points
Screen captures were provided
and labeled for compiling your 0 points
No documentation included. 5 code, and running each of your
test cases. Java style guide was not used to
prepare the Java code. Header comments include
filename, author, date and brief
purpose of the program. All instance variables not
declared private. In-line comments used to
describe major functionality of
the code.
Meaningful variable names and
prompts applied. Duplication of code was not
avoided.
any exceptions thrown by
nonnumeric inputs are not
properly handled Class names are written in
UpperCamelCase.
Variable names are written in
lowerCamelCase.
Constant names are in written
in All Capitals.
Braces use K&R style.
Declare all instance variables
private.
Avoids the duplication of code.
Any exceptions thrown by
nonnumeric inputs are properly
handled. 6
-----------------------------------------------
CS 100 #Python, cant het this code to work
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Product Description
#Python, cant het this code to work. any help will be great!
deftwoWords(length, firstLetter):
while True:
length = input('A 4 letter word please: ')
if len (length) == 4:
return length
break
while True:
firstLetter = input('A word beginning with B please: ')
if firstLetter[0] == 'b' or firstLetter[0]=='B':
return firstLetter
break
twoWords(length, firstLetter)
------------------------------------------
Cs 100 2014_midterm2: Question 11 to 13
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Question 1
for i in range(-3, 0):
print(i, end=' ')
a.
b.
c.
d.
e. no output
-3 -2 -1 0
0 -1 -2 -3
-3 -2 -1
none of the above Question 2
mess = 'hodge podge'
count = 0
idx = 0
while idx < len(mess):
if mess.count(mess[idx]) > 1:
count += mess.count(mess[idx])
else:
count += 1
idx += 1
print(count)
a.
b.
c.
d.
e. 8
9
11
18
none of the above Question 3
s = 'sliceMagic'
print(s[:] + s['M':] + s[:'M'])
a.
b.
c.
d.
e. TypeError: slice indices must be integers
sliceMagicMagicslice
sliceMagicMagicsliceM
Magicslice
none of the above Question 4
parting = 'too-da-loo'
aList = ['oo', '-', 'oo']
inCount = 0
for i in range(len(parting)-1):
if parting[i] + parting[i+1] in aList:
inCount += 1
print(inCount)
a.
b.
c.
d.
e. 1
2
3
4
none of the above Question 5
xChars = ['Mystique', 'Wolverine']
vowels = 'aeiou'
for vowel in vowels:
for char in xChars:
if vowel not in char:
continue
print(char[0], end='')
a.
b.
c.
d.
e. the empty string
MW
MWMMW
MWMWWM
none of the above Question 6
pandemics = [['HIV', 'Ebola', 'SARS'], ['polio', 'smallpox'], 'flu']
print(pandemics[2:])
a.
b.
c.
d.
e. SARS
['SARS']
['smallpox'] flu
none of the above Question 7
def returnDictVal(d, aKey):
if aKey in d:
return d[aKey]
else:
return None
chars = {'Alice':['rabbit', 'caterpiller'], 'superman':'Clark'}
wonderWomanChars = {'wonder woman':['Lynda Carter', 'Gal
Gadot']}
print(returnDictVal(chars, 'wonder woman'))
a.
b.
c.
d.
e. the empty string
None
NameError: name 'returnDictVal' is not defined
['Lynda Carter', 'Gal Gadot']
none of the above Question 8
bools = [True or False, True, True and False, True and not False]
trues = 0
for bool in bools:
if bool == True:
trues += 1
continue
break
print(trues)
a.
b.
c.
d.
e. TypeError: bool takes 1 positional argument but 2 were given
0
2
3
none of the above Question 9
anonymous = 'hollywood is the opium of the people'
def nonSubStr(t, subStr):
rtn = aList = t.split()
for s in aList:
if subStr not in s:
rtn.append(s)
return rtn
print(nonSubStr(anonymous, 'o'))
a.
b.
c.
d.
e. False ['is']
['is', 'the']
none of the above Question 10
def inFileCount(fileName, searchStr):
inF = open(fileName)
contents = inF.read()
inF.close()
return contents.count(searchStr)
seuss = open('you.txt', 'w')
seuss.write('Today you are You, that is truer than true.' + 'n')
seuss.write('There is no one alive who is Youer than You.' + 'n')
seuss.close()
print(inFileCount('you.txt', 'You'))
seuss.close()
a.
b.
c.
d.
e. 0
1
2
3
none of the above Question 11a
8 points
Write a function named rectangle() that uses turtle graphics to
draw a
rectangle of specified dimensions. The function rectangle() takes
three
parameters:
i.
t, a turtle that is used for drawing
ii. size1, the length of the first (and third) side of the rectangle
iii. size2, the length of the second (and fourth) side of the
rectangle
The function rectangle()
position and orientation
and orientation on exit.
state of the turtle. For
operations. should draw a rectangle beginning at the initial
of t, and should leave t with the same position
Do not make any assumptions about the initial
full credit you must use a loop for repeated Question 11b
12 points
Write a function named panels() that uses turtle graphics and the
function rectangle() (Question 11a) to draw a sequence of
rectangles of
specified size and orientation. Begin drawing each rectangle at the
initial
location of the passed turtle parameter. Rotate each rectangle
after the
first one counterclockwise by a specified angle. Make the second
(and
fourth) side of each rectangle twice the length of the first (and
third)
side.
The function panels() should repeatedly call rectangle() to draw
rectangles
of increasing size, rotated by a specified angle.
The function panels() takes 5 parameters:
i.
t, a turtle used for drawing
ii. initSize, the length of the short side of the first rectangle
iii. delta, the increase in length of the short side of successive
rectangles
iv. numPanels, the number of rectangles to draw
v.
angle, the number of degrees to rotate successive rectangles
If panels() is called by the following code, the graphic below
would be
correct output. (Hint: panels() should draw with the passed turtle,
whatever location and orientation the turtle is in.)
import turtle
s = turtle.Screen()
shelly = turtle.Turtle()
panels(shelly, 20, 15, 8, 20) Question 12
The letters a, e, i, o and u are the only vowels. Write a function
named
vowelUseDict() takes a string t as a parameter and computes and
returns a
dictionary with the number of words in t containing each vowel.
Assume that
the given text contains only lower case letters and white space.
Input:
Return: t, a string consisting of lower case letters and white space
a dictionary in which each vowel is a key and its value is
the number of words containing that vowel For example, the
following would be correct output.
text = 'like a vision she dances across the porch as the radio plays'
print(vowelUseDict(text))
{'e': 5, 'u': 0, 'o': 4, 'a': 6, 'i': 3}
Question 13
Write a function named longestWord() that find the length of the
longest
word in each line in a file and writes that length to a new file.
The function longestWord() takes two string parameters. The
first parameter
is the name of an input file that exists before longestWord() is
called.
The second parameter is the name of an output file that
longestWord()
creates and writes to.
Assume that the input file contains only letters and white space.
Assume
that the input file is in the current working directory and write
the
output file to that directory.
The function longestWord() should write a line to the output file
only if
the line in the input file is not empty, that is, it contains at least
one
word. For example, if the following is the content of the file
trouble.txt:
We surely got trouble
Right here in River City
Gotta figger out a way
To keep the young ones moral after school
The following function call:
inF = 'trouble.txt'
outF = 'troubleLongest.txt'
longestWord(inF, outF)
should create the file longestWord.txt with the content:
7
5
6
6
------------------------------------------
CS 100 Multiple choice questions 1-10
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Multiple choice questions 1-10 are worth 4 points each
Question 1
x = 2
for i in range(3):
print(x, end = ' ')
x += i
a.
b.
c.
d.
e. 0 1 2
2 3 5
2 2 3
1 2 4
none of the above Question 2 noise = 'hullaballoo'
idx = 0
while idx < len(noise):
let = noise[idx]
print(let, end='')
letCount = noise.count(let)
if idx > 2:
idx += letCount
else:
idx += 1
a.
b.
c.
d.
e. an infinite sequence of h's
hulal
hulll
hlaal
none of the above Question 3
s = 'GimmeASlice'
print(2*s[:5] + s[:])
a.
b.
c.
d.
e. GimmeGimmeGimmeASlice
GimmeAGimmeAGimmeASlice
SyntaxError: missing slice index
TypeError: can't multiply sequence by int
none of the above Question 4 noise = 'hullaballoo'
changeCount = 0
for i in range(1, len(noise)):
if noise[i] != noise[i-1]:
changeCount += 1
print(changeCount)
a.
b.
c.
d.
e. IndexError: string index out of range
3
4
7
none of the above Question 5 braveOnes = ['Merida', 'Elinor',
'Macintosh', 'Fergus']
vowels = 'aeiou'
for character in braveOnes:
for vowel in vowels:
if vowel in character:
continue
else:
print(character[0], end='')
break
a.
b.
c.
d.
e. no output
MMEEEMMFFF
MMMEEEMMMF
MEMF
none of the above Question 6 pandemics = [['HIV'], '', ['Ebola',
'SARS'], ['polio', 'smallpox']]
print(pandemics[1:3])
a.
b.
c.
d.
e. 'IV'
['HIV'], ''
'', ['Ebola', 'SARS']
'', ['Ebola', 'SARS'], ['polio', 'smallpox'] none of the above Question 7
def dictTest(thing, aDict):
if thing in aDict:
return thing
else:
for v in aDict.values():
if thing in v:
return v
types = {'hero':['Alice', 'superman'],'sidekick':['rabbit', 'Jimmy']}
print(dictTest('Alice', types))
a.
b.
c.
d.
e. None
'hero'
'Alice'
['Alice', 'superman']
none of the above Question 8
boolExprs = [True and False, not True, True or False, True and not
False]
fCount = 0
for expr in boolExprs:
if expr == False:
fCount += 1
else:
break
print(fCount)
a.
b.
c.
d.
e. SyntaxError: and not
1
2
3
none of the above Question 9 abe = 'no man has a good enough
memory to be a successful liar'
def wordLens(t, limit):
rtn = aList = t.split()
for s in aList:
if len(s) > limit:
return rtn
rtn.append(len(s))
return rtn
print(wordLens(abe, 5))
a.
b.
c.
d.
e. None ['no', 'man', 'has', 'a', 'good']
5
none of the above Question 10 def fileCount(fileName, s):
inF = open(fileName)
count = 0
for line in inF:
count += line.lower().count(s)
inF.close()
return count
w = open('seuss.txt', 'w')
w.write('You have brains in your head' + 'n')
w.write('You have feed in your shoes' + 'n')
w.close()
print(fileCount('seuss.txt', 'you'))
a.
b.
c.
d.
e. 2
4
0
None
none of the above Programming questions 11-13 are worth 20 points
each
Question 11a (8 points)
Write a function named halfSquare that uses turtle graphics to draw
half of a square on the screen. This
involves drawing two lines of equal length, making a 90 degree turn
after each. For full credit, these
repeated operations should be performed in a loop.
The function halfSquare takes two parameters
i. t, a turtle that is used for drawing
ii. length, the length of the lines
The function halfSquare should begin drawing without changing the
position or orientation of the turtle t. The turtle t that is passed to
halfSquare may initially be either up or down and may be at any
location on the screen and in any orientation.
The figure at the right shows sample graphical output of halfSquare.
Question 11b (12 points)
Write a function named halfSquares that calls the function halfSquare
repeatedly to draw connected
half squares of increasing size. (You can use this technique to draw a
spiral pattern.)
The function halfSquares takes four parameters:
i.
ii.
iii.
iv. t, a turtle used for drawing
initial, the length of a side of the first half square
increment, the increase in side length of each successive half square
reps, the number of half squares to draw For example, the graphical
output of the code below should
look like the illustration at the right:
import turtle
s = turtle.Screen()
turt = turtle.Turtle()
halfSquares(turt, 20, 20, 10) Question 12 (20 points)
Write a function named wordCount that counts how many words
there are in each line of an input file
and writes that count to a corresponding line of an output file. The
input file already exists when
wordCount is called. wordCount creates the output file.
Input. The function wordCount takes two parameters:
i. inFile, a string that is the name of a text file that is to be read and
analyzed. The file that inFile
refers to contains only upper and lower case letters and white space
(no punctuation marks or
other special characters).
ii. outFile, a string that is the name of the file to which wordCount
writes its output.
The input file is in the current working directory and you should
create the output file to that directory.
Output. For each line of inFile, wordCount should write a
corresponding line to outFile containing a
single integer: the number of words on the line.
If the content of the file catInTheHat.txt is below,
The sun did not shine
It was too wet to play
So we sat in the house
All that cold cold wet day
I sat there with Sally
We sat there we two
And I said How I wish
We had something to do
the function call
wordCount('catInTheHat.txt', 'catInTheHatOut.txt') should create a
file named catInTheHatOut.txt with this content:
5
6
6
6
5
5
6
5 Question 13 (20 points)
Write a function named initialVowels that analyzes the contents of a
text file for words that begin with a
vowel. The letters a, e, i, o and u are vowels.
The function initialVowels should return a dictionary of vowel:word-
list pairs. Each vowel should be a
key in the dictionary if and only if it is the first letter of some word in
the input file. The value of a key
is a list of all the words in the input file in which that vowel is the first
letter. (Hint: your job is easier if
you lowercase the text in the input file.)
Input. The function initialVowels takes a single parameter:
i. inFile, a string that is the name of a text file. This file contains only
upper and lower case letters
and white space (no punctuation marks or other special characters). It
is in the current working
directory.
Output. Return a vowel:word-list dictionary
For example, if the file named catInTheHat.txt contains the same text
as in Question 12, then the
function call
print(initialVowels('catInTheHat.txt')) should output
{'i': ['it', 'in', 'i', 'i', 'i'], 'a': ['all', 'and']}
------------------------------------------
CS 100 sumOfCubes Challenge Problem 1
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Write a function named sumOfCubes that takes a single integer
parameter, n, and returns the number of triplets of positive perfect
cubes whose sum is less than or equal to n.
For example, let n = 10. The triplets of positive perfect cubes whose
sum is less than or equal to 10 are
1, 1, 1
1, 1, 8
Therefore, sumOfCubes(10) = 2.
This problem also has a performance requirement: When n =
1,000,000 sumOfCubes must return the answer in less than one
minute.
sumOfCubes Challenge Problem 2.
We measure the efficiency (or conversely, the cost) of an algorithm
by the number of times that some key operation is performed. In this
case, the comparison between a sum of three cubes and the parameter
n is the likely measure.
Extend your solution to Problem 1 to count the number of
comparisons.
Revise your solution to try to minimize the number of comparison.
------------------------------------------
Cs 100 This homework consists of 8 problems
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
This homework consists of 8 problems. The first 7
ask that you fill in a blank in the code below. The
last problem asked you to draw some conclusions from
the data generated.
You should submit this .py file with the blanks filled
in. Problem 8 should be answered as a triple quoted
comment after the code.
'''
'''
PROBLEM 0. Put your name and assignment information here.
'''
# The Bells
# Edgar Allen Poe
theBells = '''
HEAR the sledges with the bells,
Silver bells!
What a world of merriment their melody foretells!
How they tinkle, tinkle, tinkle,
In the icy air of night!
While the stars, that oversprinkle
All the heavens, seem to twinkle
With a crystalline delight;
Keeping time, time, time,
In a sort of Runic rhyme,
To the tintinnabulation that so musically wells
From the bells, bells, bells, bells,
Bells, bells, bells—
From the jingling and the tinkling of the bells.
Hear the mellow wedding bells,
Golden bells!
What a world of happiness their harmony foretells!
Through the balmy air of night
How they ring out their delight!
From the molten-golden notes,
And all in tune,
What a liquid ditty floats
To the turtle-dove that listens, while she gloats
On the moon!
Oh, from out the sounding cells,
What a gush of euphony voluminously wells!
How it swells!
How it dwells
On the Future! how it tells
Of the rapture that impels
To the swinging and the ringing
Of the bells, bells, bells,
Of the bells, bells, bells, bells,
Bells, bells, bells—
To the rhyming and the chiming of the bells!
Hear the loud alarum bells,
Brazen bells!
What a tale of terror, now, their turbulency tells!
In the startled ear of night
How they scream out their affright!
Too much horrified to speak,
They can only shriek, shriek,
Out of tune,
In a clamorous appealing to the mercy of the fire,
In a mad expostulation with the deaf and frantic fire,
Leaping higher, higher, higher,
With a desperate desire,
And a resolute endeavor
Now—now to sit or never,
By the side of the pale-faced moon.
Oh, the bells, bells, bells!
What a tale their terror tells
Of Despair!
How they clang, and clash, and roar!
What a horror they outpour
On the bosom of the palpitating air!
Yet the ear it fully knows,
By the twanging
And the clanging,
How the danger ebbs and flows;
Yet the ear distinctly tells,
In the jangling
And the wrangling,
How the danger sinks and swells,—
By the sinking or the swelling in the anger of the bells,
Of the bells,
Of the bells, bells, bells, bells,
Bells, bells, bells—
In the clamor and the clangor of the bells!
Hear the tolling of the bells,
Iron bells!
What a world of solemn thought their monody compels!
In the silence of the night
How we shiver with affright
At the melancholy menace of their tone!
For every sound that floats
From the rust within their throats
Is a groan.
And the people—ah, the people,
They that dwell up in the steeple,
All alone,
And who tolling, tolling, tolling,
In that muffled monotone,
Feela glory in so rolling
On the human heart a stone—
They are neither man nor woman,
They are neither brute nor human,
They are Ghouls:
And their king it is who tolls;
And he rolls, rolls, rolls,
Rolls
A pæan from the bells;
And his merry bosom swells
With the pæan of the bells,
And he dances, and he yells:
Keeping time, time, time,
In a sort of Runic rhyme,
To the pæan of the bells,
Of the bells:
Keeping time, time, time,
In a sort of Runic rhyme,
To the throbbing of the bells,
Of the bells, bells, bells—
To the sobbing of the bells;
Keeping time, time, time,
As he knells, knells, knells,
In a happy Runic rhyme,
To the rolling of the bells,
Of the bells, bells, bells:
To the tolling of the bells,
Of the bells, bells, bells, bells,
Bells, bells, bells—
To the moaning and the groaning of the bells.
'''
# Canto XII from The Heights of Macchu Picchu
# Pablo Neruda
cantoXII = '''
Arise to birth with me, my brother.
Give me your hand out of the depths
sown by your sorrows.
You will not return from these stone fastnesses.
You will not emerge from subterranean time.
Your rasping voice will not come back,
nor your pierced eyes rise from their sockets.
Look at me from the depths of the earth,
tiller of fields, weaver, reticent shepherd,
groom of totemic guanacos,
mason high on your treacherous scaffolding,
iceman of Andean tears,
jeweler with crushed fingers,
farmer anxious among his seedlings,
potter wasted among his clays--
bring to the cup of this new life
your ancient buried sorrows.
Show me your blood and your furrow;
say to me: here I was scourged
because a gem was dull or because the earth
failed to give up in time its tithe of corn or stone.
Point out to me the rock on which you stumbled,
the wood they used to crucify your body.
Strike the old flints
to kindle ancient lamps, light up the whips
glued to your wounds throughout the centuries
and light the axes gleaming with your blood.
I come to speak for your dead mouths.
Throughout the earth
let dead lips congregate,
out of the depths spin this long night to me
as if I rode at anchor here with you.
And tell me everything, tell chain by chain,
and link by link, and step by step;
sharpen the knives you kept hidden away,
thrust them into my breast, into my hands,
like a torrent of sunbursts,
an Amazon of buried jaguars,
and leave me cry: hours, days and years,
blind ages, stellar centuries.
And give me silence, give me water, hope.
Give me the struggle, the iron, the volcanoes.
Let bodies cling like magnets to my body.
Come quickly to my veins and to my mouth.
Speak through my speech, and through my blood.
'''
import string
def litCricFriend(wordList, text):
''' The Literary Critic's Friend helps the humanities scholar
by computing and returning the frequency with which specified
words
(wordList) appear in a body of text (text). Frequency is
the sum of the number of times that each word in wordList
occurs, divided by the number of words in the text. A word
occurrence is the whole word, regardless of case, and
excluding punctuation.'''
# PROBLEM 1. Write a string method call that lower cases all
# of the characters in text. One line of code. Hint: assign the
# lower-cased text to a new variable name.
# PROBLEM 2. Write a string method call that replaces every
# dash ('—') in the lower-cased text with a space (' ').
# One line of code.
# PROBLEM 3. Write a string method call that splits text into a
# list of words (after they have been lower-cased, and the
# dashes removed). One line of code.
# PROBLEM 4. Write a loop that creates a new word list, using a
# string method to strip the words from the list created in
Problem 3
# of all leading and trailing punctuation. Hint: the string library,
# which is imported above, contains a constant named
punctuation.
# Three lines of code.
# PROBLEM 5. Write a loop that sums the number of times that
the
# words in wordList occur in the list from Problem 4. Hint 1: you
# can use a list method to do the counting. Hint 2: lower case the
# words in wordList. Five lines of code.
# PROBLEM 6. Calculate the ratio of the number from Problem
5
# to the number of words in text. Return this ratio. Between one
# and three lines of code. (It depends on your coding style --
# various styles are OK.)
# PROBLEM 7. Call litCricFriend() four times to find the
frequency
# of the indefinite articles 'a' and 'an' and the definite article
# 'the' in the two poems above. Print out the value returned by
# each function call, identifying what it is. For example, it might
say
# >>> bellsAAnFrequency 0.07265587064676617.
# (That is a made-up number.) Each function call takes one line.
# PROBLEM 8. Do the results show that Poe and Neruda use 'a'
and 'an'
# differently? Do the results show that Poe and Neruda use 'the'
# differently?
'''
Put your answer to PROBLEM 8 here.
------------------------------------------
CS 100 Write a function named uniqueWordsthat
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Write a function named uniqueWordsthat counts how many
different words there are in each line of an input file and writes
that count to a corresponding line of an output file. The input file
already exists when uniqueWordsis called. uniqueWordscreates
the output file. Input.The function uniqueWordstakes two
parameters: - inFile, a string that is the name of a text file that is
to be read. The file that inFile refers to contains only lower case
letters and white space (no punctuation marks or other special
characters). - outFile, a string that is the name of the file to which
uniqueWordswrites its output. The input file is in the current
working directory. uniqueWordsshould create the output file in
that directory. Output. For each line of inFile,
uniqueWordsshould write a corresponding line to
outFilecontaining a single integer: the number of unique words on
the line. If the content of the file turn.txt is below, a time to build
up a time to break down a time to dance a time to mourn a time
to cast away stones a time to gather stones together the function
call uniqueWords('turn.txt', 'turnOut.txt') should create a file
named turnOut.txt with this content: 7 5 8
------------------------------------------
CSC 110 Assignment 6 -- Voter Participation Data
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Instructions: For this assignment, you will write a program
that reads voter participation data from a file and processes that
data in several different ways, including writing a report to a
different file.
Data File Format
1952
1533500
1392594
1116414
1956
1622500
1451375
1164104
...
The voter participation data we will work with is stored in a
simple text file. Each line of the file contains one of 4 different
things:
 a year
 the estimated number of eligible voters for that year
 the number of registered voters for that year
 the number of ballots cast for that year
The file format is highly structured. Years are listed in
order. On the line after each year is the estimated number of
eligible voters for that year. On the next line is the number of
registered voters for that year. On the next line is the number of
ballots cast for that year. This sequence is repeated for each
year. The first two years of data from one of the sample files are
shown at right to illustrate this. Here are links to two sample
files: PresidentialElections.txt MidTermElections.txt [Data
source: http://www.sos.wa.gov/elections/voter_participation.aspx
(Links to an external site.)]
Program Specification
Write a program that does the following:
 Allow the user to specify the name of an input file containing
voter participation data (that way, different data files can be
tested).
 Read the data from the file and write a report out to a new
file as follows:
 The name of the output file should be the name of the
input file preceded with the word 'REPORT-'. So, if
the input file is named 'PresidentialElections.txt', then
the output file should be named 'REPORT-
PresidentialElections.txt', but if the input file is named
'MidTermElections.txt', then the output file should be
named 'REPORT-MidTermElections.txt', etc. Your
program should work with any properly formatted
data file -- not just the two listed here.
 The report should include one line for each year in the
data file. The line should show a sentence containing
the year, the percentage of eligible voters who
registered, and the percentage of eligible voters who
cast ballots (voted). The percentages should be
rounded to two places after the decimal point. Here is
an example of what the first part of the output file
would look like for the data shown above:
In 1952, 90.81% registered and 72.80% voted.
In 1956, 89.45% registered and 71.75% voted.
...
 Finally, show the following information in the Python shell
window in a nicely-formatted, easy to understand report:
 the total number of years listed
 the total number of ballots cast in all those years
 the average percentage of eligible voters who registered
 thenumberof years with less than 60% of registered
voters casting ballots
 thepercentageof years with more than 80% of
registered voters casting ballots
 A sentence showing the name of the report file
Here is an example of what the report would look like for the first
file:
The total number of years listed: 17
Total ballots cast in all these years: 34,436,792
Average percentage of eligible voters registered: 79.55%
Number of years with less than 60% of registered voters casting ballots: 0
Percentage of years with more than 80% of registered voters casting ballots:
47.1%
An output file named REPORT-PresidentialElections.txt has been created.
Development Tips:
1. Use a loop to read the data from the file and process the
data. Only one loop is needed to do everything!
2. Use acounterto count the total number of years.
3. Usecountersalong with 'if' statements inside the loop to
count the number of years with less than 60% or more than
80% of registered voters casting ballots.
4. Use anaccumulatorto add up the number of ballots
cast. You will also need one more accumulator.
5. Remember that counters and accumulators always need to
beinitializedbefore the beginning of the loop.
6. Plan your program carefully on paper before you start
writing code. Remember that you need to "process" the
fileone record at a time. You can't "jump around" to get
the info you need like you can do as a human reader. "Be
the computer!"
The easiest solution involves a loop that repeats one time for
each YEAR. Hint: if you have a line in the file with a year,
the file format guarantees that it will be followed by three
more lines containing the information for that year. As a
result, you can safely read those values into the program
right in the body of the loop.
Testing -- Be sure to carefully test your program with different
files. You can create a simple, short file to make testing easy. As
always, be sure to document your testing in comments at the end
of the program. Your comments should also say if you think any
part of the assignment requirements have not been met.
Grading
/10 correctly determines 5 quantities to be shown in the shell
window: # years, # ballots counted, average percentage of eligible
voters who registered, <60% years and >80% years
/12 reads and writes files properly (reads data, writes out a report
file, closes files, no errors)
/3 documented test cases
/5 proper comments; good variable names; declarations;
indenting; blank lines
------------------------------------------
CSC 110 This program use Python 3 Objective
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
This program use Python 3
Objective:
 Practice working with a list of numbers.
 Practice writingfunction definitionsthat
useparametersandreturna value.
 Practice using astring accumulator.
Instructions:
Your employer needs a program that analyzes the monthly sales
figures for each division.
Write a Python program that allows the user to enter a series of
numbers and places the numbers (not string values) in
a list. Each number entered by the user is the monthly sales
amount for one division. Use a sentinel-controlled loop to get
input from the user and place each value entered into the list as
long as the value is not negative. As soon as any negative value is
entered, stop the loop (without putting that illegal value into the
list).
One objective of this assignment is to apply algorithms we have
studied to solve problems. You will do this by writing a function
definitionto implement each algorithm. Every function must get
information only from its parameters, not from "global"
variables. Several of these tasks can also be accomplished with
built-in functions. In those cases, your code should demonstrate
both approaches and show that the results are the same.
Add code to your program to do the following:
1. Write a function definition that uses a loopand astring
accumulatorto produce andreturn astringresultthat
includes the user-entered sales figures formatted to look
similar to this when it is printed:
{$12.95, $1,234.56, $100.00, $20.50}
Notice the dollar signs, commas, digits after the decimal
point, and curly braces. Plan this one on paper before you
start writing code. Add code that calls this function and
prints the result.
2. Show thehighestnumber in the list -- the sales leader! Do this
in two ways. First, use the built-in 'max' function. Then,
write your own 'max2' function definition that accomplishes
the same thing by using a loop to find the highest value.
3. Show thelowestnumber in the list -- the sales loser. Do this in
two ways. First, use the built-in 'min' function. Then, write
your own 'min2' function definition that accomplishes the
same thing by using a loop to find the lowest value.
4. Show the total sales for the company for the month --
thesumof all the numbers in the list. Once again, write a
function definition that uses a loop and an accumulator to
compute this sum.
5. Show theaverageof all the numbers in the list. (Be sure to
carefully check the result!)
6. Ask the user to enter athreshold(a number). Write a
function that takes a list and the threshold as parameters,
and returns a new list that contains all values in the original
list that aregreaterthan or equal to the threshold-- these
divisions get awards for high sales! The new list may, of
course, be empty.
Program Organization:
The program should be organized as a series of function
definitions. The 'main' function should contain the user interface
as well as code that "calls" the other functions and then shows the
results to the user. Only the 'main' function should interact with
the user. No other function should print anything; rather, each
function "returns" a value. Do not use any global variables.
Testing:
As always, be sure to test each result using representative data to
make sure it is correct, and include comments showing
documented test cases in your program.
------------------------------------------
In Programming Exercise 1 in Chapter 1
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
20. C. d. In Programming Exercise 1 in Chapter 1, we defined a class
roman'rype to implement Roman numerals in a program. In that
exercise, we also implemented a fianction, roman'I'oDecimal, to
con—
vert a Roman numeral into its equivalent decimal number. Modify the
definition of the class roman'rype so that the data mem—
bers are declared as protected. Use the class string to manipulate
the strings- Furthermore, overload the stream insertion and stream
extraction operators for easy input and output. The stream insertion
operator outputs the Roman numeral in the Roman format. Also,
include a member fianction, decimalToRoman, that converts the
decimal number (the decimal number must be a positive integer) to an
equivalent Roman numeral format- Write the definition of the
member
fimction decimalToRoman. For simplicity, we aSSume that only the
letter I can appear in front of
another letter and that it appears only in ernt of the letters V and x.
For
example, 4 is represented as IV, 9 is represented as IX, 39 is
represented
as XXXIX, and 49 is represemed as XXXXIX. Also, 40 will be
represented
as moot, 19E!I will be represented as cm, and so on. Derive a class
extRomanType from the class romanType to do the
following. In the class extRomanType, overload the arithmetic
operators +, -, * , and / so that arithmetic operations can be performed
on Roman numerals- Also, overload the pre— and postincrement and
decrement operators as member fianctions of the class
extRomanType. To add (subtract, multiply, or divide) Roman
numerals, add (subtract,
multiply, or divide, respectively) their decimal representations and
then
convert the reSult to the Roman numeral format. For subtraction, if
the
first number is smaller than the sec0nd number, output a message
saying
that, “Because the first number is smaller than the second,
the numbers cannot be subtracted”. Similarly, for division, the
numerator must be larger than the denominator. Use similar conven—
tions for the increment and decrement operators. Write the definitions
of the fianctions to overload the operators
descnbed in part b. Write a program to test your class extRoman'rype.
------------------------------------------
Quiz Write a method that computes the average
FOR MORE CLASSES VISIT
www.tutorialoutlet.com
Question 1 (10 points)
Write a method that computes the average of the values in an
array of doubles.
The header of the method is as follows:
public static double average(double[] x)
Question 2 (20 points)
Write a complete Java class that will create a 2D array of
randomly generated ints with dimensions of 5 rows and 10
columns. Print the values of each cell to a 5x10 table.
(Note: a complete Java class means the code should compile and
run without issue. Be sure the output displays a set of random ints
formatted in 5 rows by 10 columns.
Question 3 (5 points)
You have an int array named examScores that is 1000 elements in
length.
Provide a single line of code that would sort the examScores.
(Note: You do not need to provide the import statements
supporting the line of code)
Question 4 (5 points)
You have an int array named examScore that is 100 elements in
length.
Provide a single line of code that would search the examScores for
values that
are 50.
(Note: You do not need to provide the import statements
supporting the line of code)
Question 5 (10 points)
Describe an application that would be a good choice for using 3D
array.
Provide the size of the array and the most likely data type.
Provide the specific Java nested loop
you would use to populate the array elements with random
values.
------------------------------------------
TECH 101 (a) What is critical thinking
For more classes visit
www.tutorialoutlet.com
(a) What is critical thinking? (b) Why is critical thinking
important? (c) Describe an incident in
your life in which the lack of critical thinking had adverse
consequences. (d) Describe an incident
in your life in which critical thinking had beneficial consequences

Mais conteúdo relacionado

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Último (20)

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Destaque (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Cis your world

  • 1. About 6 C++ code questions FOR MORE CLASSES VISIT www.tutorialoutlet.com About 6 C++ code questions. The question 1 and question 2 are just about write some comments and draw some box-and-arrow diagram to show your understanding of the given codes and outputs. We used CodeLite and Java in this term, so please make sure your codes are worked well with them. ------------------------------------------ CIS 244 Have you ever experience some kind of a virus FOR MORE CLASSES VISIT www.tutorialoutlet.com Have you ever experience some kind of a virus (any kind) on PC that have tons of pop up...Was it the problem or the process that held you up? and your computer couldn't function properly. Can you explain details of what happened? was it frustrating?
  • 2. Can you explain different ways and steps that you've adjusted or enhanced your problem solving skills to become more efficient and/or effective? 300 words or more would be great. thx 250 words or more is fine. thx ------------------------------------------ CIS 3443 Chapter 4 – Decisions and Conditions FOR MORE CLASSES VISIT www.tutorialoutlet.com Chapter 4 – Decisions and Conditions 1. What is the general format of the statement used to code decisions in an application? 2. What is a Boolean expression? 6. Why would it be useful to include the ToUpper method in a comparison? 10. Define the term validation. When is it appropriate to do validation? 12. When would it be appropriate to use a Case structure? Give an example ------------------------------------------ CMIS 141 Homework 2
  • 3. FOR MORE CLASSES VISIT www.tutorialoutlet.com Homework 2 Before attempting this project, be sure you have completed all of the reading assignments, hands-on labs, discussions, and assignments to date. Design a Java class named Polygon that contains: A private int data field named numSides that defines the number of sides of the polygon. The default value should be 4. A private double data field named sideLength that defines the length of each side. The default value should be 5.0. A private double data field named xCoord that defines the x- coordinate of the center of the polygon. The default value should be 0.0. A private double data field named yCoord that defines the y- coordinate of the center of the polygon. The default value should be 0.0. A private double data field named apothem that defines the apothem of the polygon. The default value should 5.0. A private double data filed named perimeter that defines the perimeter of the polygon. The default value should 20.0. A no argument constructor that creates a Polygon using the default number of sides, default side length, default x- and y-coordinates, and the default apothem. A constructor that creates a Polygon using a specified number of sides, side length, xand y-coordinates and the apothem Getter and setter methods for all data fields A getArea() method that returns a double value representing the area of the polygon.
  • 4. (Note the area of a regular Polgon can be calculated from ½ * Apothem*Perimeter) A toString() method that displays the number of sides, side length, x-coordinate, ycoordinate and apothem values in String format Be sure your code compiles. You should use the command prompt and not a GUI for data entry and display. Write a Java test program, named TestPolygon, to create 5 different polygons representing the 5 test cases you just created. When creating the five polygons, create one using the no argument constructor. For the remaining four, feel free to use any number of sides, side length and x-, and y-coordinates and apothem that are not equal to the default values and not equal to each other. For each of the five polygons, call all of the methods and display the results. For example for a Polygon with 3 sides, side length of 2.0 and x-coordinate and y-coordinates of 1.0, and apothem of 1.0 the following test data may result: ***Output*** toString(): (numsides=3, sideLength=2.0, xcoord=1.0,ycoord=1.0, apothem=1.0) getNumSides(): 3 getSideLength(): 2.0 getXCoord(): 1.0 getYCoord(): 1.0 getApothem():1.0 getPerimeter(): 6.0 1 getArea(): 3.0 Document your test cases in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. This table should contain 4 columns with appropriate labels and a row for each test case. An example template is shown below. Note that the actual output should be the actual results you receive when running your program and applying the
  • 5. input for the test record. Keep in mind, for five Polygons, you will have five different output results. Also, note there is no requirement to actually draw a Polygon. Example test cases: Input Constructor: numsides=3 sideLength=2.0 xcoord=1.0 ycoord=1.0 apothem=1.0 Expected Output ** Output ** Actual Output ** Output ** toString(): (numsides=3, sideLength=2.0, xcoord=1.0,ycoord=1.0, apothem=1.0) getNumSides(): 3 getSideLength(): 2.0 getXCoord(): 1.0 getYCoord(): 1.0 getApothem():1.0 getPerimeter(): 6.0 getArea(): 3.0 toString(): (numsides=3, sideLength=2.0, xcoord=1.0,ycoord=1.0, apothem=1.0) getNumSides(): 3getSideLength(): 2.0 getXCoord(): 1.0 getYCoord(): 1.0 getApothem():1.0 getPerimeter(): 6.0 getArea(): 3.0 Pass? Yes Test case 2 here Test case 3 here Test case 4 here Test case 5 here The google recommended Java style guide,
  • 6. provided as link in the week 2 content, should be used to format and document your code. Specifically, the following style guide attributes should be addressed: Header comments include filename, author, date and brief purpose of the program. In-line comments used to describe major functionality of the code. Meaningful variable names and prompts applied. Class names are written in UpperCamelCase. Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. 2 Submission requirements Deliverables include all Java files (.java) and a single word (or PDF) document. The Java files should be named appropriately for your applications. The word (or PDF) document should include screen captures showing the successful compiling and running of each of the test cases. Each screen capture should be properly labeled clearly indicated what the screen capture represents. The test cases table should be included in your word or PDF document and properly labeled as well. Submit your files to the Homework 2 assignment area no later than the due date listed in your LEO classroom. You should include your name and HW2 in your word (or PDF) file submitted (e.g. firstnamelastnamehw2.docx or firstnamelastnamehw2.pdf) Grading Rubric: The following grading rubric will be used to determine your grade: Attribute Polygon Class Meets 10 points Does not meet 0 points Private int data field named numSides that defines the number of sides of the polygon. The default value should be 4. Private int data field named numSides was not included. Private double data field named sideLength that defines the
  • 7. length of each side. The default value should be 5.0. Private double data field named xCoord that defines the xcoordinate of the center of the polygon. The default value should be 0.0. Private double data field named yCoord that defines the ycoordinate of the center of the polygon. The default value should be 0.0. Private double data field named apothem that defines the apothem of the polygon. The default value should 5.0. Private double data field named sideLength was not included Private double data field named xCoord was not included Private double data field named yCoord was not included Private double data field named apothem was not included. Private double data filed named perimeter was not included No argument constructor that creates a Polygon was not included Constructor that creates a Polygon using a specified number of sides, side length, xand y-coordinates and the apothem was not included Private double data filed named perimeter that defines the 3 perimeter of the polygon. The default value should 20.0. Getter and setter methods for all data fields were not included No argument constructor that creates a Polygon using the default number of sides, default side length, default x- and ycoordinates, and the default
  • 8. apothem. getArea() method was not included Constructor that creates a Polygon using a specified number of sides, side length, xand y-coordinates and the apothem toString() method was not included Command Line was not used for running application Getter and setter methods for all data fields getArea() method that returns a double value representing the area of the polygon. (Note the area of a regular Polgon can be calculated from ½ * Apothem*Perimeter) toString() method that displays the number of sides, side length, x-coordinate, ycoordinate and apothem values in String format Test Polygon Class Command line was used for running the application. 5 points 0 points TestPolygon used to create 5 different polygons representing the 5 test cases you just created. TestPolygon was not used to create 5 different polygons representing the 5 test cases you just created. One test cases used the no argument constructor. One test cases was not used with the no argument constructor. An additional 4 test cases with varying input values. 4 Test Cases For each of the five polygons, all of the methods were called and resulted displayed. An additional 4 test cases with varying input values were not used. Command Line was used for output. For each of the five polygons, none of the methods were
  • 9. called 5 points A minimum of 5 test cases was used in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. The table should contains 4 columns with appropriate labels and a row for each test case. Documentation and Style guide Test cases were included in the supporting word or PDF documentation. 5 points Screen captures were provided and labeled for compiling your code, and running each of your 5 test cases. Command Line was not used for output. 0 points No test cases were provided. 0 points No documentation included Java style guide was not used to prepare the Java code. Header comments include filename, author, date and brief purpose of the program. In-line comments used to describe major functionality of the code. Meaningful variable names and prompts applied. Class names are written in UpperCamelCase. 5 Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. 6
  • 10. ------------------------------------------ CMIS 141 Homework 3 FOR MORE CLASSES VISIT www.tutorialoutlet.com Homework 3 Before attempting this project, be sure you have completed all of the reading assignments, hands-on labs, discussions, and assignments to date. Create a Java class named HeadPhone to represent a headphone set. The class contains: Three constants named LOW, MEDIUM and HIGH with values of 1, 2 and 3 to denote the headphone volume. A private int data field named volume that specifies the volume of the headphone. The default volume is MEDIUM. A private boolean data field named pluggedIn that specifies if the headphone is plugged in. The default value is false. A private String data field named manufacturer that specifies the name of the manufacturer of the headphones. A private Color data field named headPhoneColor that specifies the color of the headphones. A private String data field named headPhoneModel that specifies the Model of the headphones. getter and setter methods for all data fields. A no argument constructor that creates a default headphone.
  • 11. A method named toString() that returns a string describing the current field values of the headphones. A method named changeVolume(value) that changes the volume of the headphone to the value passed into the method Create a TestHeadPhone class that constructs at least 3 HeadPhone objects. For each of the objects constructed, demonstrate the use of each of the methods. Be sure to use your IDE to accomplish this assignment. The google recommended Java style guide, provided as link in the week 2 content, should be used to format and document your code. Specifically, the following style guide attributes should be addressed: Header comments include filename, author, date and brief purpose of the program. In-line comments used to describe major functionality of the code. Meaningful variable names and prompts applied. Class names are written in UpperCamelCase. Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. Submission requirements Deliverables include all Java files (.java) and a single word (or PDF) document. The Java files should be named appropriately for your applications. The word (or PDF) document should include screen captures showing the successful compiling and running of each of the test cases. Each screen capture should be properly labeled clearly indicated what the screen capture represents. The test cases table should be included in your word or PDF document and properly labeled as well. Submit your files to the Homework 3 assignment area no later than the due date listed in your LEO classroom. You should include your name and HW3 in your word (or PDF) file submitted (e.g. firstnamelastnamehw3.docx or firstnamelastnamehw3.pdf)
  • 12. Grading Rubric: The following grading rubric will be used to determine your grade: Attribute Headphone Class Meets 10 points Does not meet 0 points Three constants named LOW, MEDIUM and HIGH with values of 1, 2 and 3 to denote the headphone volume Three constants named LOW, MEDIUM and HIGH with values of 1, 2 and 3 were not included. A private int data field named volume that specifies the volume of the headphone. The default volume is MEDIUM. A private boolean data field named pluggedIn that specifies if the headphone is plugged in. The default value is false. A private String data field named manufacturer that specifies the name of the manufacturer of the headphones. A private int data field named volume was not included. A private boolean data field named pluggedIn was not included. A private String data field named manufacturer was not included A private Color data field named headPhoneColor was not included. A private String data field named headPhoneModel wasA private Color data field named not included headPhoneColor that specifies
  • 13. the color of the headphones. getter and setter methods for all data fields were not A private String data field included. named headPhoneModel that specifies the Model of the A no argument constructor was headphones. not included. getter and setter methods for all data fields. A method named toString()was not included. A no argument constructor that creates a default headphone. A method named changeVolume(value) was not included. A method named toString() that returns a string describing the current field values of the headphones. An IDE (Netbeans or Eclipse) was not used for this assignment. A method named changeVolume(value) that changes the volume of the headphone to the value passed into the method Test Headphone Class An IDE (Netbeans or Eclipse) was used for this assignment. 5 points 0 points TestHeadPhone class was used to construct at least 3 HeadPhone objects. TestHeadPhone class was not used to construct at least 3 HeadPhone objects. For each of the objects constructed, the use of each of the methods was demonstrated For each of the objects constructed, the use of each of the methods was not demonstrated An IDE (Netbeans or Eclipse) was used for this assignment. Test Cases 5 points
  • 14. A minimum of 3 test cases was used in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. The table should contains 4 columns with appropriate labels and a row for each test case. An IDE (Netbeans or Eclipse) was not used for this assignment. 0 points No test cases were provided. Documentation and Style guide Test cases were included in the supporting word or PDF documentation. 5 points Screen captures were provided and labeled for compiling your code, and running each of your 5 test cases. Header comments include filename, author, date and brief purpose of the program. In-line comments used to describe major functionality of the code. Meaningful variable names and prompts applied. Class names are written in UpperCamelCase. Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. 0 points No documentation included
  • 15. Java style guide was not used to prepare the Java code. ------------------------------------------ CMIS 141 Homework 4 FOR MORE CLASSES VISIT www.tutorialoutlet.com Homework 4 Before attempting this project, be sure you have completed all of the reading assignments, hands-on labs, discussions, and assignments to date. Write a Java program the displays the State bird and flower. You should use your IDE for this exercise. You should also use Java classes to their full extent to include multiple methods and at least two classes. The program should prompt the user to enter a State and print both the State bird and flower. The user should be able to enter a State without worrying about case. (e.g. Users could enter Maryland, maryland, MARYLAND or any other possible combination of lower and upper case characters. States may also contain leading and trailing white spaces. Hint: Store the State information in a multidimensional array. The program should continue to prompt the user to enter a state until “None” is entered. After all States have been entered by the user, the program should display a summary of the results. You will need to do some research to find the State birds and flowers. Here is a sample run: Enter a State or None to exit: Maryland
  • 16. Bird: Baltimore Oriole Flower: Black-eyed Susan Enter a State or None to exit: Delaware Bird: Blue Hen Chicken Flower: Peach Blossom Enter a State or None to exit: None **** Thank you ***** A summary report for each State, Bird, and Flower is: Maryland, Baltimore Oriole, Black-eyed Susan Delaware, Blue Hen Chicken, Peach Blossom Please visit our site again! Create a test class that constructs at least 3 States objects. For each of the objects constructed, demonstrate the use of each of the methods. Be sure to use your IDE to accomplish this assignment. The google recommended Java style guide, provided as link in the week 2 content, should be used to format and document your code. Specifically, the following style guide attributes should be addressed: Header comments include filename, author, date and brief purpose of the program. In-line comments used to describe major functionality of the code. Meaningful variable names and prompts applied. Class names are written in UpperCamelCase. Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. Submission requirements Deliverables include all Java files (.java) and a single word (or PDF) document. The Java files should be named appropriately for your applications. The word (or PDF) document should include screen captures showing the successful compiling and running of each of the test cases. Each screen capture should be properly labeled clearly indicated what the screen capture represents. The test cases table should be included in your word or PDF document and properly labeled as well.
  • 17. Submit your files to the Homework 4 assignment area no later than the due date listed in your LEO classroom. You should include your name and HW4 in your word (or PDF) file submitted (e.g. firstnamelastnamehw4.docx or firstnamelastnamehw4.pdf) Grading Rubric: The following grading rubric will be used to determine your grade: Attribute StatesDataEntry Class Meets 10 points Does not meet 0 points The program prompts the user to enter a State and prints both the State bird and flower. The program does not prompt the user to enter a State and prints both the State bird and flower. State data entry is case insensitive. States data may also contain leading and trailing white spaces. The program continues to prompt the user to enter a state until “None” is entered. After all data has been entered by the user, the program displays a summary report of all ------------------------------------------ CMIS 141 Project 4 This programming project FOR MORE CLASSES VISIT www.tutorialoutlet.com
  • 18. Project 4 This programming project involves writing a program to manage a student database. The interface to the program should be a GUI that looks similar to the following: A combo box should allow the user to select one of the four database actions shown. The database should be implemented as a HashMap, with the ID field as the key and a student record consisting of a name and major as the value. The operation should be performed when the user clicks the Process Request button. If the user attempts to insert a key that is already in the database an error message should be displayed using a JOptionPane message dialog box. If the user attempts to delete, find or update a record that is not in the database, a message should also be displayed. After each successful operation is completed a JOptionPane window should be displayed confirming the success. In the case of a successful Find request, a window should pop up containing the student's ID, name, major and current GPA. When the user selects the Update request, the following JOptionPane windows should be displayed to gather information about a course that has just been completed: 1 This program must consist of two classes. 1. The first class should define the GUI and handle the database interactions. 2. The second class named Student, should define the student record. It must have instance variables for the student name, major and two variables that are used to compute the GPA. A variable that contains the total number of credits completed and a second variable that contains the total quality points, which are the numeric value of the grade received in a course times the number of credit hours. It should not contain the student ID. The
  • 19. class should have the following three methods: a. A constructor that is used when new student records are created. It should accept the name and major as parameters and initialize the fields that are used to compute the GPA to zero. b. The second method courseCompleted should accept the course grade and credit hours and update the variables used to compute the GPA. It will be called when an Update request is made. c. The third method should override toString and return a labeled string containing the student name, major and GPA. Finally when a student has not yet completed any course, the GPA should be displayed as 4.0. The google recommended Java style guide, provided as link in the week 2 content, should be used to format and document your code. Specifically, the following style guide attributes should be addressed: Header comments include filename, author, date and brief purpose of the program. In-line comments used to describe major functionality of the code. Meaningful variable names and prompts applied. Class names are written in UpperCamelCase. Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. In addition the following design constraints should be followed: Declare all instance variables private Avoid the duplication of code Also any exceptions thrown by nonnumeric inputs should be properly handled Test cases should be supplied in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. This table should contain 4 columns with appropriate labels and a row for each test case. Note that the actual output should be the actual results
  • 20. you receive when running your program and applying the input for the test record. Be sure to select enough different scenarios to completely test the program. Submission requirements Deliverables include all Java files (.java) and a single word (or PDF) document. The Java files should be 2 named appropriately for your applications. The word (or PDF) document should include screen captures showing the successful compiling and running of each of the test cases. Each screen capture should be properly labeled clearly indicated what the screen capture represents. The test cases table should be included in your word or PDF document and properly labeled as well. Submit your files to the Project 4 assignment area no later than the due date listed in your LEO classroom. You should include your name and P4 in your word (or PDF) file submitted (e.g. firstnamelastnameP4.docx or firstnamelastnameP4.pdf). Grading Rubric: The following grading rubric will be used to determine your grade: Attribute GUI Class Meets 40 points Does not meet 0 points Defines the GUI. Does not defines the GUI. Provides a combo box to allow the user to select one of the four database actions including insert, update, delete and find. Does not provide a combo box to allow the user to select one of the four database actions including insert, update, delete and find. The database is implemented as a HashMap, with the ID field as the key and a student record consisting of a name and major as the value.
  • 21. The operation is performed when the user clicks the Process Request button. If the user attempts to insert a key that is already in the database an error message is displayed using a JOptionPane message dialog box. If the user attempts to delete, find or update a record that is not in the database, a message is displayed. The database is not implemented as a HashMap, with the ID field as the key and a student record consisting of a name and major as the value. The operation is not performed when the user clicks the Process Request button. If the user attempts to insert a key that is already in the database an error message is not displayed using a JOptionPane message dialog box. If the user attempts to delete, find or update a record that is 3 After each successful operation is completed a JOptionPane window is displayed confirming the success. In the case of a successful Find request, a window pops-up containing the student's ID, name, major and current GPA. When the user selects the Update request, a JOptionPane windows is displayed to gather
  • 22. information about a course that has just been completed including the grade and number of credits. Student class 40 points Defines the student record. Contains instance variables for the student name, major and two variables that are used to compute the GPA. Contains a variable representing the total number of credits completed Contains a variable representing the total quality points, which are the numeric value of the grade received in a course times the number of credit hours. The class should not should contain the student ID. not in the database, a message is not displayed. After each successful operation is completed a JOptionPane window is not displayed confirming the success. In the case of a successful Find request, a window does not pop-up containing the student's ID, name, major and current GPA. When the user selects the Update request, a JOptionPane window is not be displayed to gather information about a course that has just been completed including the grade and number of credits. 0 points
  • 23. Does not define the student record. Does not contains instance variables for the student name, major and two variables that are used to compute the GPA. Does not contain a variable representing the total number of credits completed Does not contain a variable representing the total quality points, which are the numeric value of the grade received in a course times the number of credit hours. The class contains the student ID. Contains a constructor that is used when new student records are created. It should accept the Does not contains a constructor name and major as parameters that is used when new student 4 and initialize the fields that are used to compute the GPA to zero. Contains a method courseCompleted that accepts the course grade and credit hours and update the variables used to compute the GPA. courseComplete is called when an Update request is made. Contains an overridden toString method that returns a labeled string containing the student name, major and GPA. Test Cases records are created. It should accept the name and major as parameters and initialize the fields that are used to compute
  • 24. the GPA to zero. Does not contains a method courseCompleted that accepts the course grade and credit hours and update the variables used to compute the GPA. courseComplete is not called when an Update request is made. Calculates and displays a GPA of 4.0 for students who have not yet completed any course. Does not contains an overridden toString method that returns a labeled string containing the student name, major and GPA. 10 points Does not calculate or display a GPA of 4.0 for students who have not yet completed any course. 0 points Test cases are supplied in the form of table with columns indicating the input values, expected output, actual output and if the test case passed or failed. No test cases were provided. Enough scenarios selected to completely test the program. Documentation and Style guide Test cases were included in the supporting word or PDF documentation. 10 points Screen captures were provided and labeled for compiling your 0 points No documentation included. 5 code, and running each of your test cases. Java style guide was not used to prepare the Java code. Header comments include filename, author, date and brief purpose of the program. All instance variables not declared private. In-line comments used to
  • 25. describe major functionality of the code. Meaningful variable names and prompts applied. Duplication of code was not avoided. any exceptions thrown by nonnumeric inputs are not properly handled Class names are written in UpperCamelCase. Variable names are written in lowerCamelCase. Constant names are in written in All Capitals. Braces use K&amp;R style. Declare all instance variables private. Avoids the duplication of code. Any exceptions thrown by nonnumeric inputs are properly handled. 6 ----------------------------------------------- CS 100 #Python, cant het this code to work FOR MORE CLASSES VISIT www.tutorialoutlet.com Product Description #Python, cant het this code to work. any help will be great! deftwoWords(length, firstLetter):
  • 26. while True: length = input('A 4 letter word please: ') if len (length) == 4: return length break while True: firstLetter = input('A word beginning with B please: ') if firstLetter[0] == 'b' or firstLetter[0]=='B': return firstLetter break twoWords(length, firstLetter) ------------------------------------------ Cs 100 2014_midterm2: Question 11 to 13
  • 27. FOR MORE CLASSES VISIT www.tutorialoutlet.com Question 1 for i in range(-3, 0): print(i, end=' ') a. b. c. d. e. no output -3 -2 -1 0 0 -1 -2 -3 -3 -2 -1 none of the above Question 2 mess = 'hodge podge' count = 0 idx = 0 while idx &lt; len(mess): if mess.count(mess[idx]) &gt; 1: count += mess.count(mess[idx]) else: count += 1 idx += 1 print(count) a. b. c. d. e. 8 9 11 18 none of the above Question 3
  • 28. s = 'sliceMagic' print(s[:] + s['M':] + s[:'M']) a. b. c. d. e. TypeError: slice indices must be integers sliceMagicMagicslice sliceMagicMagicsliceM Magicslice none of the above Question 4 parting = 'too-da-loo' aList = ['oo', '-', 'oo'] inCount = 0 for i in range(len(parting)-1): if parting[i] + parting[i+1] in aList: inCount += 1 print(inCount) a. b. c. d. e. 1 2 3 4 none of the above Question 5 xChars = ['Mystique', 'Wolverine'] vowels = 'aeiou' for vowel in vowels: for char in xChars: if vowel not in char: continue print(char[0], end='') a. b. c.
  • 29. d. e. the empty string MW MWMMW MWMWWM none of the above Question 6 pandemics = [['HIV', 'Ebola', 'SARS'], ['polio', 'smallpox'], 'flu'] print(pandemics[2:]) a. b. c. d. e. SARS ['SARS'] ['smallpox'] flu none of the above Question 7 def returnDictVal(d, aKey): if aKey in d: return d[aKey] else: return None chars = {'Alice':['rabbit', 'caterpiller'], 'superman':'Clark'} wonderWomanChars = {'wonder woman':['Lynda Carter', 'Gal Gadot']} print(returnDictVal(chars, 'wonder woman')) a. b. c. d. e. the empty string None NameError: name 'returnDictVal' is not defined ['Lynda Carter', 'Gal Gadot'] none of the above Question 8 bools = [True or False, True, True and False, True and not False] trues = 0 for bool in bools:
  • 30. if bool == True: trues += 1 continue break print(trues) a. b. c. d. e. TypeError: bool takes 1 positional argument but 2 were given 0 2 3 none of the above Question 9 anonymous = 'hollywood is the opium of the people' def nonSubStr(t, subStr): rtn = aList = t.split() for s in aList: if subStr not in s: rtn.append(s) return rtn print(nonSubStr(anonymous, 'o')) a. b. c. d. e. False ['is'] ['is', 'the'] none of the above Question 10 def inFileCount(fileName, searchStr): inF = open(fileName) contents = inF.read() inF.close() return contents.count(searchStr) seuss = open('you.txt', 'w') seuss.write('Today you are You, that is truer than true.' + 'n') seuss.write('There is no one alive who is Youer than You.' + 'n')
  • 31. seuss.close() print(inFileCount('you.txt', 'You')) seuss.close() a. b. c. d. e. 0 1 2 3 none of the above Question 11a 8 points Write a function named rectangle() that uses turtle graphics to draw a rectangle of specified dimensions. The function rectangle() takes three parameters: i. t, a turtle that is used for drawing ii. size1, the length of the first (and third) side of the rectangle iii. size2, the length of the second (and fourth) side of the rectangle The function rectangle() position and orientation and orientation on exit. state of the turtle. For operations. should draw a rectangle beginning at the initial of t, and should leave t with the same position Do not make any assumptions about the initial full credit you must use a loop for repeated Question 11b 12 points Write a function named panels() that uses turtle graphics and the function rectangle() (Question 11a) to draw a sequence of rectangles of specified size and orientation. Begin drawing each rectangle at the initial
  • 32. location of the passed turtle parameter. Rotate each rectangle after the first one counterclockwise by a specified angle. Make the second (and fourth) side of each rectangle twice the length of the first (and third) side. The function panels() should repeatedly call rectangle() to draw rectangles of increasing size, rotated by a specified angle. The function panels() takes 5 parameters: i. t, a turtle used for drawing ii. initSize, the length of the short side of the first rectangle iii. delta, the increase in length of the short side of successive rectangles iv. numPanels, the number of rectangles to draw v. angle, the number of degrees to rotate successive rectangles If panels() is called by the following code, the graphic below would be correct output. (Hint: panels() should draw with the passed turtle, whatever location and orientation the turtle is in.) import turtle s = turtle.Screen() shelly = turtle.Turtle() panels(shelly, 20, 15, 8, 20) Question 12 The letters a, e, i, o and u are the only vowels. Write a function named vowelUseDict() takes a string t as a parameter and computes and returns a dictionary with the number of words in t containing each vowel. Assume that the given text contains only lower case letters and white space. Input: Return: t, a string consisting of lower case letters and white space a dictionary in which each vowel is a key and its value is
  • 33. the number of words containing that vowel For example, the following would be correct output. text = 'like a vision she dances across the porch as the radio plays' print(vowelUseDict(text)) {'e': 5, 'u': 0, 'o': 4, 'a': 6, 'i': 3} Question 13 Write a function named longestWord() that find the length of the longest word in each line in a file and writes that length to a new file. The function longestWord() takes two string parameters. The first parameter is the name of an input file that exists before longestWord() is called. The second parameter is the name of an output file that longestWord() creates and writes to. Assume that the input file contains only letters and white space. Assume that the input file is in the current working directory and write the output file to that directory. The function longestWord() should write a line to the output file only if the line in the input file is not empty, that is, it contains at least one word. For example, if the following is the content of the file trouble.txt: We surely got trouble Right here in River City Gotta figger out a way To keep the young ones moral after school The following function call: inF = 'trouble.txt' outF = 'troubleLongest.txt' longestWord(inF, outF) should create the file longestWord.txt with the content: 7
  • 34. 5 6 6 ------------------------------------------ CS 100 Multiple choice questions 1-10 FOR MORE CLASSES VISIT www.tutorialoutlet.com Multiple choice questions 1-10 are worth 4 points each Question 1 x = 2 for i in range(3): print(x, end = ' ') x += i a. b. c. d. e. 0 1 2 2 3 5 2 2 3 1 2 4 none of the above Question 2 noise = 'hullaballoo' idx = 0 while idx &lt; len(noise): let = noise[idx] print(let, end='') letCount = noise.count(let) if idx &gt; 2: idx += letCount
  • 35. else: idx += 1 a. b. c. d. e. an infinite sequence of h's hulal hulll hlaal none of the above Question 3 s = 'GimmeASlice' print(2*s[:5] + s[:]) a. b. c. d. e. GimmeGimmeGimmeASlice GimmeAGimmeAGimmeASlice SyntaxError: missing slice index TypeError: can't multiply sequence by int none of the above Question 4 noise = 'hullaballoo' changeCount = 0 for i in range(1, len(noise)): if noise[i] != noise[i-1]: changeCount += 1 print(changeCount) a. b. c. d. e. IndexError: string index out of range 3 4 7 none of the above Question 5 braveOnes = ['Merida', 'Elinor', 'Macintosh', 'Fergus']
  • 36. vowels = 'aeiou' for character in braveOnes: for vowel in vowels: if vowel in character: continue else: print(character[0], end='') break a. b. c. d. e. no output MMEEEMMFFF MMMEEEMMMF MEMF none of the above Question 6 pandemics = [['HIV'], '', ['Ebola', 'SARS'], ['polio', 'smallpox']] print(pandemics[1:3]) a. b. c. d. e. 'IV' ['HIV'], '' '', ['Ebola', 'SARS'] '', ['Ebola', 'SARS'], ['polio', 'smallpox'] none of the above Question 7 def dictTest(thing, aDict): if thing in aDict: return thing else: for v in aDict.values(): if thing in v: return v types = {'hero':['Alice', 'superman'],'sidekick':['rabbit', 'Jimmy']} print(dictTest('Alice', types)) a.
  • 37. b. c. d. e. None 'hero' 'Alice' ['Alice', 'superman'] none of the above Question 8 boolExprs = [True and False, not True, True or False, True and not False] fCount = 0 for expr in boolExprs: if expr == False: fCount += 1 else: break print(fCount) a. b. c. d. e. SyntaxError: and not 1 2 3 none of the above Question 9 abe = 'no man has a good enough memory to be a successful liar' def wordLens(t, limit): rtn = aList = t.split() for s in aList: if len(s) &gt; limit: return rtn rtn.append(len(s)) return rtn print(wordLens(abe, 5)) a. b.
  • 38. c. d. e. None ['no', 'man', 'has', 'a', 'good'] 5 none of the above Question 10 def fileCount(fileName, s): inF = open(fileName) count = 0 for line in inF: count += line.lower().count(s) inF.close() return count w = open('seuss.txt', 'w') w.write('You have brains in your head' + 'n') w.write('You have feed in your shoes' + 'n') w.close() print(fileCount('seuss.txt', 'you')) a. b. c. d. e. 2 4 0 None none of the above Programming questions 11-13 are worth 20 points each Question 11a (8 points) Write a function named halfSquare that uses turtle graphics to draw half of a square on the screen. This involves drawing two lines of equal length, making a 90 degree turn after each. For full credit, these repeated operations should be performed in a loop. The function halfSquare takes two parameters i. t, a turtle that is used for drawing ii. length, the length of the lines The function halfSquare should begin drawing without changing the position or orientation of the turtle t. The turtle t that is passed to
  • 39. halfSquare may initially be either up or down and may be at any location on the screen and in any orientation. The figure at the right shows sample graphical output of halfSquare. Question 11b (12 points) Write a function named halfSquares that calls the function halfSquare repeatedly to draw connected half squares of increasing size. (You can use this technique to draw a spiral pattern.) The function halfSquares takes four parameters: i. ii. iii. iv. t, a turtle used for drawing initial, the length of a side of the first half square increment, the increase in side length of each successive half square reps, the number of half squares to draw For example, the graphical output of the code below should look like the illustration at the right: import turtle s = turtle.Screen() turt = turtle.Turtle() halfSquares(turt, 20, 20, 10) Question 12 (20 points) Write a function named wordCount that counts how many words there are in each line of an input file and writes that count to a corresponding line of an output file. The input file already exists when wordCount is called. wordCount creates the output file. Input. The function wordCount takes two parameters: i. inFile, a string that is the name of a text file that is to be read and analyzed. The file that inFile refers to contains only upper and lower case letters and white space (no punctuation marks or other special characters). ii. outFile, a string that is the name of the file to which wordCount writes its output. The input file is in the current working directory and you should create the output file to that directory.
  • 40. Output. For each line of inFile, wordCount should write a corresponding line to outFile containing a single integer: the number of words on the line. If the content of the file catInTheHat.txt is below, The sun did not shine It was too wet to play So we sat in the house All that cold cold wet day I sat there with Sally We sat there we two And I said How I wish We had something to do the function call wordCount('catInTheHat.txt', 'catInTheHatOut.txt') should create a file named catInTheHatOut.txt with this content: 5 6 6 6 5 5 6 5 Question 13 (20 points) Write a function named initialVowels that analyzes the contents of a text file for words that begin with a vowel. The letters a, e, i, o and u are vowels. The function initialVowels should return a dictionary of vowel:word- list pairs. Each vowel should be a key in the dictionary if and only if it is the first letter of some word in the input file. The value of a key is a list of all the words in the input file in which that vowel is the first letter. (Hint: your job is easier if you lowercase the text in the input file.) Input. The function initialVowels takes a single parameter: i. inFile, a string that is the name of a text file. This file contains only upper and lower case letters and white space (no punctuation marks or other special characters). It
  • 41. is in the current working directory. Output. Return a vowel:word-list dictionary For example, if the file named catInTheHat.txt contains the same text as in Question 12, then the function call print(initialVowels('catInTheHat.txt')) should output {'i': ['it', 'in', 'i', 'i', 'i'], 'a': ['all', 'and']} ------------------------------------------ CS 100 sumOfCubes Challenge Problem 1 FOR MORE CLASSES VISIT www.tutorialoutlet.com Write a function named sumOfCubes that takes a single integer parameter, n, and returns the number of triplets of positive perfect cubes whose sum is less than or equal to n. For example, let n = 10. The triplets of positive perfect cubes whose sum is less than or equal to 10 are 1, 1, 1 1, 1, 8 Therefore, sumOfCubes(10) = 2. This problem also has a performance requirement: When n = 1,000,000 sumOfCubes must return the answer in less than one minute. sumOfCubes Challenge Problem 2.
  • 42. We measure the efficiency (or conversely, the cost) of an algorithm by the number of times that some key operation is performed. In this case, the comparison between a sum of three cubes and the parameter n is the likely measure. Extend your solution to Problem 1 to count the number of comparisons. Revise your solution to try to minimize the number of comparison. ------------------------------------------ Cs 100 This homework consists of 8 problems FOR MORE CLASSES VISIT www.tutorialoutlet.com This homework consists of 8 problems. The first 7 ask that you fill in a blank in the code below. The last problem asked you to draw some conclusions from the data generated. You should submit this .py file with the blanks filled in. Problem 8 should be answered as a triple quoted comment after the code. '''
  • 43. ''' PROBLEM 0. Put your name and assignment information here. ''' # The Bells # Edgar Allen Poe theBells = ''' HEAR the sledges with the bells, Silver bells! What a world of merriment their melody foretells! How they tinkle, tinkle, tinkle, In the icy air of night! While the stars, that oversprinkle All the heavens, seem to twinkle With a crystalline delight; Keeping time, time, time, In a sort of Runic rhyme, To the tintinnabulation that so musically wells From the bells, bells, bells, bells,
  • 44. Bells, bells, bells— From the jingling and the tinkling of the bells. Hear the mellow wedding bells, Golden bells! What a world of happiness their harmony foretells! Through the balmy air of night How they ring out their delight! From the molten-golden notes, And all in tune, What a liquid ditty floats To the turtle-dove that listens, while she gloats On the moon! Oh, from out the sounding cells, What a gush of euphony voluminously wells! How it swells! How it dwells On the Future! how it tells Of the rapture that impels To the swinging and the ringing Of the bells, bells, bells,
  • 45. Of the bells, bells, bells, bells, Bells, bells, bells— To the rhyming and the chiming of the bells! Hear the loud alarum bells, Brazen bells! What a tale of terror, now, their turbulency tells! In the startled ear of night How they scream out their affright! Too much horrified to speak, They can only shriek, shriek, Out of tune, In a clamorous appealing to the mercy of the fire, In a mad expostulation with the deaf and frantic fire, Leaping higher, higher, higher, With a desperate desire, And a resolute endeavor Now—now to sit or never, By the side of the pale-faced moon. Oh, the bells, bells, bells! What a tale their terror tells
  • 46. Of Despair! How they clang, and clash, and roar! What a horror they outpour On the bosom of the palpitating air! Yet the ear it fully knows, By the twanging And the clanging, How the danger ebbs and flows; Yet the ear distinctly tells, In the jangling And the wrangling, How the danger sinks and swells,— By the sinking or the swelling in the anger of the bells, Of the bells, Of the bells, bells, bells, bells, Bells, bells, bells— In the clamor and the clangor of the bells! Hear the tolling of the bells, Iron bells!
  • 47. What a world of solemn thought their monody compels! In the silence of the night How we shiver with affright At the melancholy menace of their tone! For every sound that floats From the rust within their throats Is a groan. And the people—ah, the people, They that dwell up in the steeple, All alone, And who tolling, tolling, tolling, In that muffled monotone, Feela glory in so rolling On the human heart a stone— They are neither man nor woman, They are neither brute nor human, They are Ghouls: And their king it is who tolls; And he rolls, rolls, rolls, Rolls A pæan from the bells;
  • 48. And his merry bosom swells With the pæan of the bells, And he dances, and he yells: Keeping time, time, time, In a sort of Runic rhyme, To the pæan of the bells, Of the bells: Keeping time, time, time, In a sort of Runic rhyme, To the throbbing of the bells, Of the bells, bells, bells— To the sobbing of the bells; Keeping time, time, time, As he knells, knells, knells, In a happy Runic rhyme, To the rolling of the bells, Of the bells, bells, bells: To the tolling of the bells, Of the bells, bells, bells, bells, Bells, bells, bells— To the moaning and the groaning of the bells.
  • 49. ''' # Canto XII from The Heights of Macchu Picchu # Pablo Neruda cantoXII = ''' Arise to birth with me, my brother. Give me your hand out of the depths sown by your sorrows. You will not return from these stone fastnesses. You will not emerge from subterranean time. Your rasping voice will not come back, nor your pierced eyes rise from their sockets. Look at me from the depths of the earth, tiller of fields, weaver, reticent shepherd, groom of totemic guanacos, mason high on your treacherous scaffolding, iceman of Andean tears, jeweler with crushed fingers, farmer anxious among his seedlings,
  • 50. potter wasted among his clays-- bring to the cup of this new life your ancient buried sorrows. Show me your blood and your furrow; say to me: here I was scourged because a gem was dull or because the earth failed to give up in time its tithe of corn or stone. Point out to me the rock on which you stumbled, the wood they used to crucify your body. Strike the old flints to kindle ancient lamps, light up the whips glued to your wounds throughout the centuries and light the axes gleaming with your blood. I come to speak for your dead mouths. Throughout the earth let dead lips congregate, out of the depths spin this long night to me as if I rode at anchor here with you.
  • 51. And tell me everything, tell chain by chain, and link by link, and step by step; sharpen the knives you kept hidden away, thrust them into my breast, into my hands, like a torrent of sunbursts, an Amazon of buried jaguars, and leave me cry: hours, days and years, blind ages, stellar centuries. And give me silence, give me water, hope. Give me the struggle, the iron, the volcanoes. Let bodies cling like magnets to my body. Come quickly to my veins and to my mouth. Speak through my speech, and through my blood. ''' import string
  • 52. def litCricFriend(wordList, text): ''' The Literary Critic's Friend helps the humanities scholar by computing and returning the frequency with which specified words (wordList) appear in a body of text (text). Frequency is the sum of the number of times that each word in wordList occurs, divided by the number of words in the text. A word occurrence is the whole word, regardless of case, and excluding punctuation.''' # PROBLEM 1. Write a string method call that lower cases all # of the characters in text. One line of code. Hint: assign the # lower-cased text to a new variable name. # PROBLEM 2. Write a string method call that replaces every # dash ('—') in the lower-cased text with a space (' '). # One line of code.
  • 53. # PROBLEM 3. Write a string method call that splits text into a # list of words (after they have been lower-cased, and the # dashes removed). One line of code. # PROBLEM 4. Write a loop that creates a new word list, using a # string method to strip the words from the list created in Problem 3 # of all leading and trailing punctuation. Hint: the string library, # which is imported above, contains a constant named punctuation. # Three lines of code. # PROBLEM 5. Write a loop that sums the number of times that the # words in wordList occur in the list from Problem 4. Hint 1: you # can use a list method to do the counting. Hint 2: lower case the # words in wordList. Five lines of code.
  • 54. # PROBLEM 6. Calculate the ratio of the number from Problem 5 # to the number of words in text. Return this ratio. Between one # and three lines of code. (It depends on your coding style -- # various styles are OK.) # PROBLEM 7. Call litCricFriend() four times to find the frequency # of the indefinite articles 'a' and 'an' and the definite article # 'the' in the two poems above. Print out the value returned by # each function call, identifying what it is. For example, it might say # >>> bellsAAnFrequency 0.07265587064676617. # (That is a made-up number.) Each function call takes one line. # PROBLEM 8. Do the results show that Poe and Neruda use 'a' and 'an' # differently? Do the results show that Poe and Neruda use 'the' # differently? '''
  • 55. Put your answer to PROBLEM 8 here. ------------------------------------------ CS 100 Write a function named uniqueWordsthat FOR MORE CLASSES VISIT www.tutorialoutlet.com Write a function named uniqueWordsthat counts how many different words there are in each line of an input file and writes that count to a corresponding line of an output file. The input file already exists when uniqueWordsis called. uniqueWordscreates the output file. Input.The function uniqueWordstakes two parameters: - inFile, a string that is the name of a text file that is to be read. The file that inFile refers to contains only lower case letters and white space (no punctuation marks or other special characters). - outFile, a string that is the name of the file to which uniqueWordswrites its output. The input file is in the current working directory. uniqueWordsshould create the output file in that directory. Output. For each line of inFile, uniqueWordsshould write a corresponding line to outFilecontaining a single integer: the number of unique words on the line. If the content of the file turn.txt is below, a time to build up a time to break down a time to dance a time to mourn a time to cast away stones a time to gather stones together the function call uniqueWords('turn.txt', 'turnOut.txt') should create a file named turnOut.txt with this content: 7 5 8 ------------------------------------------ CSC 110 Assignment 6 -- Voter Participation Data
  • 56. FOR MORE CLASSES VISIT www.tutorialoutlet.com Instructions: For this assignment, you will write a program that reads voter participation data from a file and processes that data in several different ways, including writing a report to a different file. Data File Format 1952 1533500 1392594 1116414 1956 1622500 1451375 1164104 ... The voter participation data we will work with is stored in a simple text file. Each line of the file contains one of 4 different things:  a year  the estimated number of eligible voters for that year  the number of registered voters for that year  the number of ballots cast for that year The file format is highly structured. Years are listed in order. On the line after each year is the estimated number of eligible voters for that year. On the next line is the number of
  • 57. registered voters for that year. On the next line is the number of ballots cast for that year. This sequence is repeated for each year. The first two years of data from one of the sample files are shown at right to illustrate this. Here are links to two sample files: PresidentialElections.txt MidTermElections.txt [Data source: http://www.sos.wa.gov/elections/voter_participation.aspx (Links to an external site.)] Program Specification Write a program that does the following:  Allow the user to specify the name of an input file containing voter participation data (that way, different data files can be tested).  Read the data from the file and write a report out to a new file as follows:  The name of the output file should be the name of the input file preceded with the word 'REPORT-'. So, if the input file is named 'PresidentialElections.txt', then the output file should be named 'REPORT- PresidentialElections.txt', but if the input file is named 'MidTermElections.txt', then the output file should be named 'REPORT-MidTermElections.txt', etc. Your program should work with any properly formatted data file -- not just the two listed here.  The report should include one line for each year in the data file. The line should show a sentence containing the year, the percentage of eligible voters who registered, and the percentage of eligible voters who cast ballots (voted). The percentages should be rounded to two places after the decimal point. Here is an example of what the first part of the output file would look like for the data shown above:
  • 58. In 1952, 90.81% registered and 72.80% voted. In 1956, 89.45% registered and 71.75% voted. ...  Finally, show the following information in the Python shell window in a nicely-formatted, easy to understand report:  the total number of years listed  the total number of ballots cast in all those years  the average percentage of eligible voters who registered  thenumberof years with less than 60% of registered voters casting ballots  thepercentageof years with more than 80% of registered voters casting ballots  A sentence showing the name of the report file Here is an example of what the report would look like for the first file: The total number of years listed: 17 Total ballots cast in all these years: 34,436,792 Average percentage of eligible voters registered: 79.55% Number of years with less than 60% of registered voters casting ballots: 0 Percentage of years with more than 80% of registered voters casting ballots: 47.1% An output file named REPORT-PresidentialElections.txt has been created. Development Tips: 1. Use a loop to read the data from the file and process the data. Only one loop is needed to do everything! 2. Use acounterto count the total number of years.
  • 59. 3. Usecountersalong with 'if' statements inside the loop to count the number of years with less than 60% or more than 80% of registered voters casting ballots. 4. Use anaccumulatorto add up the number of ballots cast. You will also need one more accumulator. 5. Remember that counters and accumulators always need to beinitializedbefore the beginning of the loop. 6. Plan your program carefully on paper before you start writing code. Remember that you need to "process" the fileone record at a time. You can't "jump around" to get the info you need like you can do as a human reader. "Be the computer!" The easiest solution involves a loop that repeats one time for each YEAR. Hint: if you have a line in the file with a year, the file format guarantees that it will be followed by three more lines containing the information for that year. As a result, you can safely read those values into the program right in the body of the loop. Testing -- Be sure to carefully test your program with different files. You can create a simple, short file to make testing easy. As always, be sure to document your testing in comments at the end of the program. Your comments should also say if you think any part of the assignment requirements have not been met. Grading /10 correctly determines 5 quantities to be shown in the shell window: # years, # ballots counted, average percentage of eligible voters who registered, <60% years and >80% years /12 reads and writes files properly (reads data, writes out a report file, closes files, no errors) /3 documented test cases /5 proper comments; good variable names; declarations; indenting; blank lines ------------------------------------------
  • 60. CSC 110 This program use Python 3 Objective FOR MORE CLASSES VISIT www.tutorialoutlet.com This program use Python 3 Objective:  Practice working with a list of numbers.  Practice writingfunction definitionsthat useparametersandreturna value.  Practice using astring accumulator. Instructions: Your employer needs a program that analyzes the monthly sales figures for each division. Write a Python program that allows the user to enter a series of numbers and places the numbers (not string values) in a list. Each number entered by the user is the monthly sales amount for one division. Use a sentinel-controlled loop to get input from the user and place each value entered into the list as long as the value is not negative. As soon as any negative value is entered, stop the loop (without putting that illegal value into the list). One objective of this assignment is to apply algorithms we have studied to solve problems. You will do this by writing a function definitionto implement each algorithm. Every function must get information only from its parameters, not from "global" variables. Several of these tasks can also be accomplished with
  • 61. built-in functions. In those cases, your code should demonstrate both approaches and show that the results are the same. Add code to your program to do the following: 1. Write a function definition that uses a loopand astring accumulatorto produce andreturn astringresultthat includes the user-entered sales figures formatted to look similar to this when it is printed: {$12.95, $1,234.56, $100.00, $20.50} Notice the dollar signs, commas, digits after the decimal point, and curly braces. Plan this one on paper before you start writing code. Add code that calls this function and prints the result. 2. Show thehighestnumber in the list -- the sales leader! Do this in two ways. First, use the built-in 'max' function. Then, write your own 'max2' function definition that accomplishes the same thing by using a loop to find the highest value. 3. Show thelowestnumber in the list -- the sales loser. Do this in two ways. First, use the built-in 'min' function. Then, write your own 'min2' function definition that accomplishes the same thing by using a loop to find the lowest value. 4. Show the total sales for the company for the month -- thesumof all the numbers in the list. Once again, write a function definition that uses a loop and an accumulator to compute this sum. 5. Show theaverageof all the numbers in the list. (Be sure to carefully check the result!) 6. Ask the user to enter athreshold(a number). Write a function that takes a list and the threshold as parameters, and returns a new list that contains all values in the original list that aregreaterthan or equal to the threshold-- these divisions get awards for high sales! The new list may, of course, be empty. Program Organization: The program should be organized as a series of function
  • 62. definitions. The 'main' function should contain the user interface as well as code that "calls" the other functions and then shows the results to the user. Only the 'main' function should interact with the user. No other function should print anything; rather, each function "returns" a value. Do not use any global variables. Testing: As always, be sure to test each result using representative data to make sure it is correct, and include comments showing documented test cases in your program. ------------------------------------------ In Programming Exercise 1 in Chapter 1 FOR MORE CLASSES VISIT www.tutorialoutlet.com 20. C. d. In Programming Exercise 1 in Chapter 1, we defined a class roman'rype to implement Roman numerals in a program. In that exercise, we also implemented a fianction, roman'I'oDecimal, to con— vert a Roman numeral into its equivalent decimal number. Modify the definition of the class roman'rype so that the data mem— bers are declared as protected. Use the class string to manipulate the strings- Furthermore, overload the stream insertion and stream extraction operators for easy input and output. The stream insertion operator outputs the Roman numeral in the Roman format. Also, include a member fianction, decimalToRoman, that converts the decimal number (the decimal number must be a positive integer) to an equivalent Roman numeral format- Write the definition of the member fimction decimalToRoman. For simplicity, we aSSume that only the
  • 63. letter I can appear in front of another letter and that it appears only in ernt of the letters V and x. For example, 4 is represented as IV, 9 is represented as IX, 39 is represented as XXXIX, and 49 is represemed as XXXXIX. Also, 40 will be represented as moot, 19E!I will be represented as cm, and so on. Derive a class extRomanType from the class romanType to do the following. In the class extRomanType, overload the arithmetic operators +, -, * , and / so that arithmetic operations can be performed on Roman numerals- Also, overload the pre— and postincrement and decrement operators as member fianctions of the class extRomanType. To add (subtract, multiply, or divide) Roman numerals, add (subtract, multiply, or divide, respectively) their decimal representations and then convert the reSult to the Roman numeral format. For subtraction, if the first number is smaller than the sec0nd number, output a message saying that, “Because the first number is smaller than the second, the numbers cannot be subtracted”. Similarly, for division, the numerator must be larger than the denominator. Use similar conven— tions for the increment and decrement operators. Write the definitions of the fianctions to overload the operators descnbed in part b. Write a program to test your class extRoman'rype. ------------------------------------------ Quiz Write a method that computes the average FOR MORE CLASSES VISIT www.tutorialoutlet.com
  • 64. Question 1 (10 points) Write a method that computes the average of the values in an array of doubles. The header of the method is as follows: public static double average(double[] x) Question 2 (20 points) Write a complete Java class that will create a 2D array of randomly generated ints with dimensions of 5 rows and 10 columns. Print the values of each cell to a 5x10 table. (Note: a complete Java class means the code should compile and run without issue. Be sure the output displays a set of random ints formatted in 5 rows by 10 columns. Question 3 (5 points) You have an int array named examScores that is 1000 elements in length. Provide a single line of code that would sort the examScores. (Note: You do not need to provide the import statements supporting the line of code) Question 4 (5 points)
  • 65. You have an int array named examScore that is 100 elements in length. Provide a single line of code that would search the examScores for values that are 50. (Note: You do not need to provide the import statements supporting the line of code) Question 5 (10 points) Describe an application that would be a good choice for using 3D array. Provide the size of the array and the most likely data type. Provide the specific Java nested loop you would use to populate the array elements with random values. ------------------------------------------ TECH 101 (a) What is critical thinking For more classes visit www.tutorialoutlet.com (a) What is critical thinking? (b) Why is critical thinking important? (c) Describe an incident in your life in which the lack of critical thinking had adverse consequences. (d) Describe an incident in your life in which critical thinking had beneficial consequences