Example Algorithms
The following are some example algorithms for problems (see also the first program in the demo
folder in the General Material Module).
Example 1: Suppose you were asked to calculate the area of a triangle.
Purpose: Calculate the area of
1. Purpose: To determine how many cases company XYZ would produce with the same number
of candy bars produced by company ABC
Input needed: Number of cases produced by company ABC
Output expected: Number of cases produced by company XYZ with that same numb
CMPSC 201 Fall 2017
Programming Project 1
To be done individually
Worth 40points
Due by 11:00 pm on 9/26/15
Goals: Developing problem-solving skills, declaring variables, multi-way branches, data
validation.
Problem: Complete Programming Challenge 4.19 in
Algorithm 1
Problem 1:
Purpose: Calculate how many cases of candy bars both companies will produce given the fact
that they both pack the same number of candy bars.
Input Needed: The number of cases packed by Company ABC.
Output Expected: The number of ca
Lab 3
CMPSC 201 Fall 2017
Due by the end of your recitation section on 9/15/17
Implement a solution for problem 3 from the Algorithms 12 assignment. Note the following
directions. Make sure that you use appropriate data type for all variables, include the
Algorithm 3
Problem 1:
Purpose: To create a process that adds the series 1+x+x^2+x^3+x^n
Input Needed: A value for n that will determine the number of x multipliers there are.
Output Expected: A series that goes up to the n value that was inputted.
Algori
Algorithm 5
Problem 1:
Purpose: To make change in the least amount of coins possible.
Input Needed: An exact dollar/cent amount for the change needed.
Output Expected: the amount of each coin for the change.
Algorithm:
Ask the user for a change amount
Cre
Algorithm 4
Problem 1:
Purpose: To display the sales of each store in terms of asterisks, with 1 asterisk as $100.
Input Needed: Sales numbers for each store, rounded to the nearest hundred.
Output Expected: A line of asterisks for each store, representin
Algorithm 2
Problem 1:
Purpose: To calculate the number of days, hours, minutes, and seconds based on a given
number of seconds.
Input Needed: Any number of seconds.
Output Expected: The number of days, hours, minutes, and seconds based on the number of
s
Algorithm 1
Problem 1:
Purpose: Calculate how many cases of candy bars both companies will produce given the fact
that they both pack the same number of candy bars.
Input Needed: The number of cases packed by Company ABC.
Output Expected: The number of ca
Algorithm 5
Problem 1:
Purpose: To make change in the least amount of coins possible.
Input Needed: An exact dollar/cent amount for the change needed.
Output Expected: the amount of each coin for the change.
Algorithm:
Ask the user for a change amount
Cre
1. Purpose: To determine the force between two bodies using the formula F= (G * M1 * M2) / d *
d where G is the gravitational constant 6.673 * 10 ^ -11
Input : the masses of the bodies and the distance between them
Output: The force acting between the bod
CMPSC 201- Fall 2017
Lecture 1
August 21, 2017
Welcome to
CMPSC 201
Instructor
Dr. Susan L. Quick
Office: W112 Westgate Building (formerly IST)
Phone: 865-9507
e-mail: [email protected] or CANVAS (do not
use any other e-mail!)
Office hours: M 4:45 5:
Algorithm 1
CMPSC 201
Due as stated on CANVAS
Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what
input is needed from whomever is using the process, what output is expected, the step by step
process (algorithm) to get
CMPSC 201 Fall 2016
Lab 2
To be done individually
Due by end of your recitation section on 9/9/16.
Goals: Practicing variable definitions (declarations) and arithmetic operations.
Implement one of the 3 problems given the Algorithms 1 assignment into C+.
CMPSC 201- Fall 2017
Lecture 2
August 25, 2017
What is an Engineer (Scientist)?
Programming Languages
High-level languages: designed to be easy for humans to read
and to write programs in, but too complicated for the
computer to understand (see Table 1.1
CMPSC 201- Fall 2017
Lecture 4
January 18, 2017
First Lab on Friday
Bring a USB (jump, flash) drive with you to class.
Create a folder on your university V-drive (your
personal space on the U-drive) to store your work
for this class.
Arithmetic Operator
Ryan Kelly, rjk5427
CMPSC Algorithm 1
Problem 1: Suppose you needed to calculate the number of cases of candy bars that would be produced by 2 different companies (Company ABC and XYZ) if they produced the same number of bars
with differing number of ca
COMPUTER SCIENCE 201
Fall 2017
Professor: Dr. Susan L. Quick
Office:
W112 Westgate
E-mail:
Phone: 865-9507
[email protected] or through Canvas (Do not use any other e-mail address!)
Office Hours: M 4:45 5:30 pm and W 11:00 1:30 or by appointment (request
CMPSC 201- Fall 2017
Lecture 5
August 30, 2017
Data Overflow and Underflow
C+ does not check for data being within range
of data type.
How the data is stored may be compiler
dependent.
In many compilers, the number will wrap. For
example given the foll
Ryan Kelly, rjk5427
Algorithm 3
Problem 1: Create a process to evaluate a series, 1+x+x^2.+x^n, with n being positive, exponentiation should not be used.
Input needed: x as any number, n as a positive number
Output expected: a summation of all terms in th
Onto the Animal Portion!
Chapter 40
Intro to Animal Form
Test will cover sections 40.1 and 40.3
only (as far as Ch. 40 goes)
You do NOT have to memorize the
material from pages 871-873
(exploring structure and function in
animal tissues) for the exam
Anim
Ryan Kelly, rjk5427
Algorithm2
Problem 1: Create a program to determine the number of days, hours, minutes and seconds that would be the same as an inputted number of seconds, and only display non-zero terms.
Input needed: Any number of seconds
Output exp
CMPSC 121 Fall 2017
Labs 1-3 makeup
To be done individually
Section 1
Due by end of your class time on 9/22/17
Do not use any concepts beyond Chapter 5 of your textbook!
Goals: Practicing switch control structures and while loops
Problem: Write a program