Tarrant County College District Programming Worksheet

Description

7 attachmentsSlide 1 of 7attachment_1attachment_1attachment_2attachment_2attachment_3attachment_3attachment_4attachment_4attachment_5attachment_5attachment_6attachment_6attachment_7attachment_7

Unformatted Attachment Preview

COSC 2425 S22
Program Set #1
Total Points: 30
Three problems must be implemented for full credit. Each section will state how many problems to
implement within it. The required (starred) problem marked in the set must be implemented by
everyone. See the 2425 Grading and Submission Guide Sheets for additional grading/submission
information. Partial credit will be given. (10 points each)
Note: If coding in C++, use the STL string class for the problems involving strings. Do not use C style
strings.
Section One- Choose two problems.
1. Your friend is suspicious that the hard drive he just bought for his computer said 1EB on the box, but
when he plugged it into his computer the operating system says it only has 931PB of space. That’s
because hard drive marketing uses base-10 to calculate space, but computer science (and operating
systems) use base-2 (and always have). So, using base-10, 1 Exabyte (EB) would be 1018
(1,000,000,000,000,000,000) bytes, but in base-2 it would be 260 (1,152,921,504,606,846,976)
bytes. Most humans use base-10 when counting, so there that’s the confusion. Write a program that will
take storage space given in base-10 and convert it to base-2 using the tables below for reference.
Input from the keyboard the computer hard drive size as a whole integer, a space, then a 2-letter size
code reported in base-10 SI units from the marketing text on the box. Output to the screen the
converted size given in base-10 to base-2 units which will be reported in the operating system, rounded
to the nearest 2 decimal places in the largest binary size you can express a whole number in (For
example, do not write 1030 MiB, write 1.01 GiB). Finally, ask the user if he/she wishes to run the
program again (check case). Refer to the sample output below.
Sample Run:
Enter the hard drive size: 1 TB
1
COSC 2425 S22
The corresponding binary drive size: 931.32 GiB
Run again (Y/N): y
Enter the hard drive size: 752 MB
The corresponding binary drive size: 717.16 MiB
Run again (Y/N): N
Name the program: StoreConversionXX.cpp or StoreConversionXX.java, where XX are your
initials.
2. Write a program given a number in any base (through base 16) and rounds that number to a specified
place. Rounding up happens when the digit to the right of the rounding place divided by the number’s
base is 0.5 or more. For example, 0.12468 rounded to 3 places is 0.125 because 6 divided by 8 is
greater than 0.5; when rounded to 2 places, it’s 0.13 because 4 divided by 8 is 0.5; and it’s 0.1 when
rounded to 1 place because 2 divided by 8 is less than 0.5. Input from the keyboard three (3) values: a
number, the base of that number, and the number of places to be rounded. Assume the numbers
entered will have at least one digit to the right of the place to be rounded and at least one digit to the
left of the decimal point and assume the rounding place will never be 0 (round a whole number).
For each input, output to the screen the number rounded to the given number of places. Do not print
any digits beyond the rounded place. Finally, ask the user if he/she wishes to run the program again
(check case). Refer to the sample output below.
Sample Run:
Enter the value: 0.11101
Enter the base of the number: 2
Number of decimal places to round: 4
The resulting value: 0.1111
Run again (Y/N): y
Enter the value: 35.4321
Enter the base of the number: 7
Number of decimal places to round: 3
The resulting value: 35.432
Run again (Y/N): N
Name the program: BaseRounderXX.cpp or BaseRounderXX.java, where XX are your initials.
2
COSC 2425 S22
3. Something went horribly wrong with the encrypted document backup process at the college and all
files were converted to strings containing 1’s and 0’s representing the binary representation of the file.
Write a program to restore all the files. All the original files were in 16-bit Unicode. Input from a text file
containing a long string of 1’s and 0’s whose length is guaranteed to be a multiple of 16. Output to the
screen the original file contents. Let the user input the file name from the keyboard. Refer to the
sample output below.
Sample File:
0010101000000000000101100000000010010110000000001100111000000000000001000000000010010
1100000000011001110000000000000010000000000001011100000000000010110000000001010011000
0000000000010000000000111101100000000001001110000000001001011000000000111001100000000
0100101100000000001110110000000001000011000000000001101100000000000000100000000000110
0110000000001001011000000000001101100000000010100110000000000111010000000000101100000
0000000010100000000000010110000000000000101000000000000111000100000000011110110000000
0011110110000000000010011000000000000001000000000000101110000000000001011000000000100
1011000000000011101100000000011100110000000000000010000000000100111100000000011110110
0000000010101110000000000000010000000000010011100000000010100110000000001100011000000
0001111011000000000011011100000000010100110000000000100111000000000101001100000000000
100110000000000000010000000000100101100000000000101110000000001000010000000000
(The actual input file contains only one line which appears to span many lines here in the problem.)
Sample Run:
Enter file name: expansion.txt
This is the original file.
Good thing you recovered it!
Name the program: DeExpansionXX.cpp or DeExpansionXX.java, where XX are your initials.
Required Problem- Comprehensive.
4 (**). Write a program to convert a 64-bit binary floating-point number into a base 10 decimal. Like
any base, binary numbers can have a decimal point: 1001.112 is a perfectly valid binary number. Each
bit to the left of the decimal point stands for a power of 2(20,21,22…). Similarly, each bit to the right
stands for a negative power (2-1,2-2,2-3). 1001.112 = 23+20+2-1+2-2 = 9.7510. The decimal point
however cannot be represented as a 1 or 0. To solve this problem, all fractional binary numbers used by
computers are represented in scientific notation: mantissa x 2exponent. For example, 1001.112 would
become 1.001112 x 23. To create floating point numbers, the scientific notation is compressed into a
block of bits. Binary numbers stored as doubles take the following form:
3
COSC 2425 S22
Example:
0 10000000010 0011100000000000000000000000000000000000000000000000
where:
Sign
Exponent
Mantissa (Fraction)
Converting to a decimal
A single bit that represents the sign of the number: 0 if a positive
number, 1 if negative. In the example above, 0 tells us the
number is positive.
11 bits that represent the exponent-102310. In the example
above, 100000000102 = 102610. 102610 – 102310 = 310,
representing 23. (The subtraction of 1023 allows for negative
exponents)
The 52-bit mantissa represents the significant digits of the
number. The first bit stands for 2-1, the second 2-2, and so on.
Since scientific notation leaves only one option for the bit to
the left of the binary point (1), it is implicitly added to the
mantissa. In the example above, the mantissa is:
2-3 + 2-4 + 2-5 = .2187510 + 110 = 1.2187510.
Plug each part into the scientific notation formula:
mantissa x 2exponent. So, 1.2187510 x 23 = 9.7510.
Input will be from a data file; the first line will contain a single integer n that indicates the number of
data sets to follow. Each data set will contain a 64-bit floating point binary number on a single line. The
number will be between 100000010 and -100000010. Output to the screen each data set labeled with the
floating-point number as a decimal value rounded to 2 places. Let the user input the file name from the
keyboard. Refer to the sample output below.
Sample File:
3
0100000000001001001000011111101101010100010001000010110100011000
1100000000010000110011001100110011001100110011001100110011001101
0100000101100110111100011101101011001111110111001100011000111111
Sample Run:
Enter file name: floating.txt
Set 1: 3.14
Set 2: -4.20
Set 3: 12029654.50
Name the program: FloatToBase10XX.cpp or FloatToBase10XX.java, where XX are your initials.
4
COSC 2425 S22
Extra Credit: Implement the following problem. See the 2425 Grading and Submission Guide Sheets
for additional grading/submission information. Partial credit will be given. (10 points)
One can compare the vowels in words of the same length at the same positions. By using bitwise
operations, one can determine if the letters in both words are vowels, or not, or if only one letter was a
vowel and the other a consonant. Vowels for this problem are the letters a e i o u. Write a program
given two words of equal length, convert the word to a binary number for the AND (&), OR(|), and
XOR(^) operators. For example, the words happy and shops:
happy
shops
00000 = 0 (AND – no chars are both vowels)
01100 = 12 (OR – 2nd and 3rd chars are vowels)
01100 = 12 (XOR is the same as OR for these words)
Input from the keyboard two words of equal length on separate lines. Each word is less than 32
characters and at least 1 character. Assume proper input. Output to the screen the bitwise &, |, and ^
decimal value for each word pair, labeled, on one line separated by a space. Finally, ask the user if
he/she wishes to run the program again (check case). Refer to the sample output below.
Sample Run:
Enter string 1: happy
Enter string 2: shops
AND: 0 OR: 12 XOR: 12
Run again (Y/N): y
Enter string 1: at
Enter string 2: in
AND: 2 OR: 2 XOR: 0
Run again (Y/N): N
Name the program: BitWordsXX.cpp or BitWordsXX.java, where XX are your initials.
5
COSC 2425 S22
Course Grading

This document provides additional grading information used this term. See the Syllabus (ICR)
under Canvas for more information.
Programs:




There will be 3 (three) programming sets given this term. Three problems in the set count toward
the individual program grade. The set may contain one or more sections/topics and a required
problem. Each section will state how many problems to implement within it. The required (starred)
problem marked in the set must be implemented by everyone and counts as one of the three
problems that count toward your grade.
Each individual programming problem will be worth 10 (ten) points each and partial credit will be
given. Points for each problem will be divided into the following categories:
Category
Value
Score
Code meets all requirements in problem specification
and functions correctly. Includes elimination of all
warnings.
Correctness
6
Style and Quality of code
(efficiency)
2
Easy to understand solution/efficient. Readable.
Follows basic rules of structured programming.
Documentation/Testing
2
Correct documentation and coding standards followed
in all cases. Proper program submission directions. Test
cases cover program specifications.
Total Points
10
Other grading issues:
o A program will automatically receive only 5 points if:
 It does not compile or suffers a runtime error.
 A proper source file (.java/.cpp/.asm) was not submitted with the problem.
In either or both cases above, no additional points will be awarded.
o If all problems are implemented, the required program and the first problems listed per
section will only be graded.
o If three non-required problems are implemented only the first two program listed (nonextra credit) programs will be graded.
Program set grades are calculated as follows:
(total points earned / total point value) * 100
Example: 19/20 = .95 * 100 = 95

Programs will be based both upon the weekly lessons/readings, regardless of whether the
lessons/readings were covered online, that were due up to and including the due date of the
1
COSC 2425 S22






programming set, and upon the material covered online up to the moment of the program set due,
regardless of whether the assigned lessons/readings also covered the same material.
Programs must be turned in via Canvas on/before the stated due date and must be turned in under
the correct assignment. If something was failed to be submitted, it will not be graded- This includes
submitting previous programs not originally submitted or from other classes.
Two submission attempts per program will be given (before due date). The latest program set
submission will be used for grading; feedback will not be provided on earlier submissions. The
student cannot resubmit their program after the due date for a higher grade.
Programs submitted late will follow the same grading/submission standards as stated above.
For late work only, if the original grade is 65 or less- the late penalty will be waived.
No e-mails or printouts of your programs will be accepted. No group work allowed.
The makeup programming set follows the same rules as the regular program sets.
Extra Credit:
• Extra credit can only be earned by implementing the problem marked as extra credit. A maximum of
10 points extra credit can be earned. No extra credit can be earned for doing other non-marked
problems.
• Extra credit is graded on the same program scale listed above. Extra credit cannot be used to replace
the problems in the set, and partial credit can be earned on the extra credit problem.
• Extra credit will be added after the program grade has been calculated and does not carry over from
any program set.
Quizzes


There will be 6 (six) quizzes given this term. Quizzes will be based both upon the weekly
lessons/readings, regardless of whether the lessons/readings were covered online, that were due up
to and including the due date of the programming set, and upon the material covered online up to
the moment of the program set due, regardless of whether the assigned lessons/readings also
covered the same material.
All quizzes will be worth a total point value. The individual quiz grades are calculated as follows:
(total points earned / total point value) * 100
Example: 19/20 = .95 * 100 = 95




A student will have 2 attempts per quiz to take the quiz. The average of the two quiz attempts will be
taken. No quiz attempts will be reset.
If any quiz is submitted to any e-mail address-it will not be graded. All quizzes will be done
online in Canvas.
Quiz solutions will be provided once grades have been posted.
Extra credit will be given on each quiz. Points earned the same way as mentioned above under
Programs.
2
COSC 2425 S22
Exams



There will be 1 (one) exam given this term. The exam will be based both upon the reading
assignments and notes from the entire semester (comprehensive).
The exam will be worth a total point value. Each question will have individual point values as well.
The individual exam grade is calculated as follows:
(total points earned / total point value) * 100
Example: 19/20 = .95 * 100 = 95



The final exam in this class will be administered using Proctorio which is an online proctoring
service. Proctorio is available 24/7. Students can use their own computer from home. The computer
must be equipped with a webcam and microphone. Most computers/laptops already meet these
requirements. More information about using Proctorio will be provided during the semester.
No e-mail or printout of your exam will be accepted. No group work allowed.
Extra credit will be given on the exam. Points earned the same way as mentioned above under
Programs.
3
COSC 2425 S22
Program Documentation and Submission Guidelines

This document provides additional information for use with programming assignments this term.
See the Syllabus (ICR) under Canvas for more information.
General Overview

The topic breakdown of the sets are as follows:




PS 1- Number Systems, Number Conversion, Bitwise
PS 2- Boolean Algebra/Expressions, FSA, KMap, CRC Codes, etc. (Harder problems)
PS 3- Assembly Language
Make Up- Comprehensive (Mix of P1-P3 topics)
The topics in PS 1 and PS 2 will be relevant to the topics covered in the textbook or in notes. The extra
credit problems on the quizzes and the exam will follow the same idea.
Program Documentation


All code submitted must follow the coding standards from previous classes and modifications as
specified below. Good style is what makes a program readable. That is key-if it’s readable, then it’s
understandable, modifiable, testable, and debuggable.
Every Java/C++ or Assembly program turned must have a leading comment block that identifies the
author, course, program set, and any references used. All programs/projects must have a leading
comment header similar to below:
C++/Java
//
//
//
//
Author: Your Name
Course: COSC 2425
Program Set 1
Comments: None
Assembly/MASM
;
;
;
;

Author: Your Name
Course: COSC 2425
Program Set 3
Comments: None
If code is borrowed from other sources- cite it in the comment block. If you find it necessary to
obtain help from someone else in completing your assignment, you are required to indicate that by
clearly marking it in your program. There is nothing wrong with using the code from an existing
program as a template for a new program. Professional programmers do that all the time. However,
if you do that, you should do it in a thoughtful and judicious way. One should, however, understand
the code and give credit where it is found.
1
COSC 2425 S22
Program Submission
For each program set:
• Create a folder. Name the folder with your last name. Inside the folder add the following:
o Only the applicable source code files (.java/.cpp/.asm) for each problem. Include any
extra credit. Data files do not need to be included.
o A sample run(s) for each problem showing actual input and all values output including
all test cases in a text file or a screen shot in a .docx (Word) file.
• Zip the named folder. “Zipping” files (.zip format) is a way to compress them (make them
smaller). More important for this class, it is also a way to combine multiple files into a single file
that can be easily uploaded and downloaded. Do not use .rar or any archive format other than
.zip.

Submit the single .zip file by going to Canvas and submitting in the appropriate location. Your
submission should consist of multiple files in the named zipped folder.
Notes:
• The professor will run individual programs to make sure the programs work. Remember your
programs will be tested using Visual C++/Apache NetBeans/MASM compilers depending on the
language. It is your responsibility to use the correct compiler and submit the correct files.
• The instructor really does not need to grade your assignment- you know how you did. Do not ask
the instructor to check your assignment before turning it in for a grade. Thus, there should be no
major surprises if points are lost for a problem.
Other General Guidelines








If the professor does not specify a data structure/format in the problem -then implement the
program whichever way you wish. Suggest using the simplest code/way possible. If the professor
does not specify a data structure/format in the problem -then implement the program whichever
way you wish. Suggest using the simplest code/way possible. If you have a choice between writing
code that runs quickly and writing code that is easy to understand, make it easy to understand.
Never pursue efficiency at the expense of clarity.
If the problem says, “Refer to the sample output below.” that means the output in your program
should be similar if not exactly like the example given. You have a little freedom but stay as close as
possible.
Keep the code straightforward, simple, and elegant, and follow any data structure requirements.
Input/output should be user friendly- do not leave anyone guessing on what to do.
Your program test data should not be hard-coded in your program (unless specified in the problem
to do so). The test data should be input from the keyboard or from an input file as specified in the
problem.
The instructor will test your program with other data sets than those examples given with the
problem. Those additional judging sets will not be provided to you.
Do not modify any data files if given to you by the instructor to be used for a specific problem.
Always explicitly open, close, and check for valid files. All data files names must be entered from the
keyboard.
2
COSC 2425 S22

Do not use break, continue, or goto statements, unless the break is used within a switch
statement.
C++ Specific


No programs will be written using graphics.
In a Visual C++ console program, if the output window closes quickly add the following as the last
statement in the main() function:
cin.get();



//Hold the output window
When creating your project in VC++ select an empty project. Otherwise, the compiler will add
additional code that will likely not let your program compile.
Eliminate all warnings with the VC++ compiler. Most compiler warnings are easy to correct.
Do not include the following directives:
#include “stdafx.h”
OR
#include
These are non-standard C++ header files and are non-portable. Using these could cause your programs
not to compile when grading.
Java Specific



No programs will be written using GUIs (JavaFX, Swing, AWT, or Applets)
Use Scanner for text input and println/printf for text output. No GUI dialog boxes.
No user defined packages within your code. They are not needed. If a package is used full credit will
not be given with the problem.
//My Comments Here
package nopackage;
//Oops…delete me
public class NoPackage{
public static void main(String[] args){
}
}

The .java file has the same name as the public main() class in the program. If the names are
different full credit will not be given with the problem
public class Find{
public static void main(String args[]){
}
}
3
COSC 2425 S22
The file name would be: Find.java

Do not use deprecated or unchecked code. Make sure to use proper generic classes.
Assembly Specific

Do not use any textbook author created specific libraries. For example:
Irvine16.lib
Irvine32.inc
4

Purchase answer to see full
attachment

Explanation & Answer:
Worksheet

Tags:
science

programming

computer

User generated content is uploaded by users for the purposes of learning and should be used following Studypool’s honor code & terms of service.

Reviews, comments, and love from our customers and community:

Article Writing

Keep doing what you do, I am really impressed by the work done.

Alexender

Researcher

PowerPoint Presentation

I am speechless…WoW! Thank you so much!

Stacy V.

Part-time student

Dissertation & Thesis

This was a very well-written paper. Great work fast.

M.H.H. Tony

Student

Annotated Bibliography

I love working with this company. You always go above and beyond and exceed my expectations every time.

Francisca N.

Student

Book Report / Review

I received my order wayyyyyyy sooner than I expected. Couldn’t ask for more.

Mary J.

Student

Essay (Any Type)

On time, perfect paper

Prof. Kate (Ph.D)

Student

Case Study

Awesome! Great papers, and early!

Kaylin Green

Student

Proofreading & Editing

Thank you Dr. Rebecca for editing my essays! She completed my task literally in 3 hours. For sure will work with her again, she is great and follows all instructions

Rebecca L.

Researcher

Critical Thinking / Review

Extremely thorough summary, understanding and examples found for social science readings, with edits made as needed and on time. Transparent

Arnold W.

Customer

Coursework

Perfect!

Joshua W.

Student

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>