2 Pages

115 Project 01 - Candy Store

Course: CS 115, Fall 2009
School: Wheaton College
Rating:
 
 
 
 
 

Word Count: 776

Document Preview

Fundamentals The Programming Candy Store Due Date: Tuesday, September 28, 2004 Youre 10 years old. No, really, you are. Just humor me for a moment. PROJECT #1 Youre 10 years old, and you loooooove chocolate. You love it so much that you save every cent you can get your hands on mostly from going through the couch cushions and raiding your parents nightstands so you can go to the center of town and buy...

Register Now

Unformatted Document Excerpt

Coursehero

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Fundamentals The Programming Candy Store Due Date: Tuesday, September 28, 2004 Youre 10 years old. No, really, you are. Just humor me for a moment. PROJECT #1 Youre 10 years old, and you loooooove chocolate. You love it so much that you save every cent you can get your hands on mostly from going through the couch cushions and raiding your parents nightstands so you can go to the center of town and buy chocolates at the local candy shop. Its all good chocolate at this store, but you do have favorites. Your absolute favorites are the Ton o Chocolate Turtles big as the palm of your hand, and filled with the worlds BEST caramel. Next you love the Nutty Cups, peanut butter cups that put Reeses to absolute shame. After those, you drool for the Death by Chocolate Truffles (chocolate outer shells, and gushy chocolate insides). And last but not least, you love the Twisters pretzels dipped in white chocolate. These are the relative costs of your favorites, in order of preference: Ton o Chocolate Turtles Nutty Cups Death by Chocolate Truffles Twisters $2.25 each $0.90 each $0.55 each $0.07 each Your mission is to take the money in your pocket and maximize the chocolate bliss you can buy with it. You first want to buy as many Turtles as you can afford. With what is left, buy as many Nutty Cups as you can. With the remainder, buy as many Truffles as you can. Finally, buy as many Twisters as you can with what little is left over. Figure out how many you can buy of each candy and print out how many you are buying, how much you spent, and how much you have left in an output like this example, for the starting amount $4.85: Candy Amount Price ------------------------------------------------------Ton o Chocolate Turtles 1 $2.25 Nutty Cups 2 $1.80 Death by Chocolate Truffles 1 $0.55 Twisters 3 $0.21 ------------------------------------------------------TOTAL $4.81 ------------------------------------------------------Leftover: $0.04 Your output does not have to look EXACTLY like this, but it needs to have all of this information justified in columns, with the decimal points lined up. Your program will start by asking how much money is in your pocket which will be entered in the form: 3.45 Page 1 of 2 Read this number in You carefully! are going to need to do modulo arithmetic in this problem; therefore, you need to manipulate all of the numbers as integers, not floating point numbers. Therefore, do all of your math with amounts that discuss how many cents you have as a whole integer number so, an input of 3.45 will have to be converted into the integer 345. One way to do this would be to read it as a float, multiply it by 100, and cast the result as an integer. Work with the prices for each candy as cents and not dollars as well i.e., the Turtles are worth 150 cents. Once your program has the input for the amount you are starting with, it has to figure out how much to buy of each and print the result in a nice output like what is above. Since you are working with integers, you will have to figure out how to print out the costs as dollars and cents. Here are the niddly details of the project: Start with an algorithm first write out in English the steps you think you will need to do in order to get the data you need, and then figure out exactly what to buy. Turn this in by Friday, September 17, in class. This will be part of your grade. When you write your actual program, follow the Programming Style Guidelines, including: the header at the top of the program; comments for the variables you declare; and appropriate comments for each major ste...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Wheaton College - CS - 115
Programming FundamentalsDo you want fries with that? Due Date: Tuesday, October 12, 2004PROJECT #2You have been hired to put together a mock-up for the cash registers at the world-famous "Snarky Burger" fast food restaurant. Your cash register program
Wheaton College - CS - 115
Programming FundamentalsCan robots walk a line? Due Date: Wednesday, October 27, 2004PROJECT #3This is now an extra credit project. Please note that the points distribution has been changed. In this project, you are going to use a Lego robot to follow
Wheaton College - CS - 115
Programming FundamentalsREVISED ROBOT PROJECT Due Date: Wednesday, October 27, 2004This is the revised robot project.PROJECT #3Your task is now to write a program assuming that the robot is starting somewhere in a box: Your robot should drive forward
Wheaton College - CS - 115
Programming FundamentalsPROJECT #4The ghost of fractions past haunted by grade school math Due Date: Friday, November 5, 2004From the darkness of your educational past, a ghost has arisen your third grade math teacher. You had hoped to forget her, but
Wheaton College - CS - 115
Programming Fundamentals(Smarter than your AVERAGE Lyon) Due Date: Tuesday, November 16, 2004PROJECT #5Once again, youre going to write a program to help out a teacher except this time, its a college professor. Your program is going to read from a data
Wheaton College - CS - 115
Programming Fundamentals(Arrayed in Your Finest) Due Date: Tuesday, November 30, 2004PROJECT #6Its your first job out of college and you get hired by a cool online company to design their ordering system! Your project will print the catalog of choices
Wheaton College - CS - 116
Pile of Dirty LaundryWow, this is quite impressive. Either the owner of these clothes has an extremely extensive wardrobe, or she must be working pretty hard these days to find something to wear. The pile has reached the height of your knees, and you hav
Wheaton College - CS - 116
/=/ COMP 116 Lecture Examples// RECURSION - main program/#include <iostream>using namespace std;/=/ defining an array to demonstrate these/#define ARRAY_SIZE 15int SortedArray[] = cfw_ 1,3,6,8,10,22,34,45,60,67,72,76,89,92,100;int RandomArray[
Wheaton College - CS - 116
Data StructuresSTL iterator examples#include <stdlib.h> #include <vector> int main() cfw_ vector<char> name; vector<char>:iterator i; vector<char>:reverse_iterator r; char c; / obtain contents of name vector cout < "Enter your name & hit return: "; do c
Wheaton College - CS - 116
Data StructuresSTL vector classAN INTRODUCTION TO STL VECTORS URL for more info: http:/www.sgi.com/tech/stl/ Vector.htmlHandoutAs introduced in lecture, a vector can be seen mostly as a dynamic array. It is an ordered sequence, it can be randomly acce
Wheaton College - CS - 116
Data Structurespoint class (overloaded operators)Handout/ flower.h : a class to hold information about a flower.#include <string> class flower cfw_ public: float GetPollenAmount(); bool operator=( const flower& ); flower& operator=( const flower& ); p
Wheaton College - CS - 116
Data Structurespoint class (overloaded operators) point.h:Handout/ point.h : Defining a class to store the x,y coordinates in a plane / includes overloaded operators for input, output, comparison, / addition, and assignment #include <iostream> class po
Wheaton College - CS - 116
Data Structuresreview class review.h:Handout/ review.h : defines a class to store a review of a computer game / for a website on gaming. / possible genres of computer games enum GenreType cfw_FPS, RPG, ADVENTURE, PUZZLE, STRATEGY, SIM, ACTION; / minimu
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceProlog Due Date: Fri, 2/29/08 Name your Prolog source file YourlastnameHW4.pl and submit it to my dropbin when you are completed. Comment each predicate as you would comment a function/method and include a sta
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceKnowledge Representation Due Date: Wednesday 4/9/08 1. (20 points) Come up with a script representation of a process you deal with on a regular basis, constructed of a minimum of 4 scenes, using the same forma
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceScripts ExampleScripts Handout Page 1 of 2Scripts Handout Page 2 of 2
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceNatural Language Processing ExamplesPronoun resolution examples1. John and Mike: a. He has been acting quite odd. He called up Mike Yesterday. John wanted to meet him quite urgently. b. He has been acting qu
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceIntroduction to PrologBasic Prolog Syntax Programs are made of two kinds of sentences, including facts, simple predicates that are true about the world and the objects in it: male(fred). male(bob). male(frank
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceMore Forward and Backward ChainingFrom Lewis Carrolls Logic Puzzles: No interesting poems are unpopular among people of real taste. [1] x Interesting(x) Popular(x) No modern poetry is free from affectation. [
Wheaton College - CS - 255
ComputerScience255:ArtificialIntelligenceBackward ChainingBackward chaining uses Modus Ponens in the opposite direction. If you want to prove Q, and you know that P Q .then you try to prove P, and that will prove Q. The general approach is the following
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceForward ChainingRecall that Modus Ponens says that if you have the implication P Q And you know that P is true, then Q must be true. The way forward chaining works is the following: Find all implications in y
Wheaton College - CS - 255
ComputerScience255:ArtificialIntelligenceLogical InferenceAND-INTRODUCTION: If you have two sentences each which are known to be true: P is true Q is true Brilliant( Mary ) Funny( Mary ) Mary is brilliant. Mary is funny.then you know their conjunction
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligenceFirst Order (Predicate) Logic"ATOMIC" SENTENCES in First-Order Logic: Indivisible propositions which are either TRUE or FALSE. They are written as predicates and usually express a fact, or a relationship, abo
Wheaton College - CS - 255
Computer Science 255: Artificial IntelligencePropositional Logic"ATOMIC" SENTENCES: Indivisible propositions which are either TRUE or FALSE. Usually expresses a fact, or a relationship. Noah is cute. Malory is Lisa's pet. Noah plays with a ball. Sue gav
Wheaton College - CS - 106
The BASICS of COMPUT I NGdue Friday, 9/21/071. (1 pt) General gate questions:HW #3: Logica. What are the three notational methods for describing the behavior of gates and circuits? What is the common information which is conveyed in different ways in
Wheaton College - CS - 106
The BASICS of COMPUTINGdue Friday, 10/5/07HW #5: Objects and Methods1. (1 pt) If we are given an object called human which has the following subparts: head body And the head had the following subpart: eyes While the human had the following properties:
Wheaton College - CS - 106
The BASICS of COMPUT I NG HW #6: If/else and More Objectsdue Friday, 10/12/071. (2 pts) Pick the letter below that best fits the description: A. Variable B. Property C. Method D. Function E. Expression a. b. c. d. e. f. g. h. An instruction that returns
Wheaton College - CS - 106
The BASICS of COMPUT I NGdue Friday, 10/19/07HW #7: Loops1. (1 point) Identify each of these as being an (E)vent controlled loop, or a (C)ounter controlled loop. a. A loop which executes something 7 times every time you run the program. b. A loop which
Wheaton College - CS - 106
The BASICS OF COMPUT I NGThe Game of PigProject #1Due: Friday, November 9In this project, you will be creating a playable version of the game PIG, in which two players roll a die in a race to get to 100 points. During a turn, a player can accumulate p
Wheaton College - CS - 106
The BASICS of COMPUT I NG WWWdue Friday, 11/16/07HW #11: Networks and the(7 pts) For the following, identify the term that goes with the description possible answers are: A. B. C. D. E. F. G. bandwidth data transfer rate HTML attribute <head></head> <b
Wheaton College - CS - 106
-Go to Main Menu <./DataArchive.html>Go to Power Search </cgi-bin/iform?DASL>Go to Datafile Subjects <./allsubjects.html>-*Datafile Name:* Hot dogs *Datafile Subjects:* Food</cgi-bin/isearchb?DATABASE=DASL&SEARCH_TYPE=boolean&ELEMENT_SET=title&MAX
Wheaton College - CS - 106
Lisa MichaudProject #2Page 1 out of 3Chart 1 : Composition of Data Set by Type31% 100% 90% 80% 70% 60% 50% 40% 30% 20% 10% 0%Chart 2 : Percentage of Hot Dogs Which are High-Calorie37% Beef Meat Poultry31%BeefMeatPoultryChart 3 : Calories by Typ
Wheaton College - CS - 106
The BASICS of COMPUT I NGExample SubmissionsProposalPROJECT #2The file I have chosen to do my analysis on is the Hot Dogs file. This file contains information about the composition type, calories, and sodium level of 54 different brands of hot dogs. T
Wheaton College - CS - 106
The BASICS of COMPUT I NGProposal Due: Friday, November 16, 2007 Final Due Date: Wednesday, November 28, 2007SummaryPROJECT #2Data Analysis and Presentation Using SpreadsheetsNow that you have some experience using a spreadsheet to do both data proje
Wheaton College - CS - 106
The BASICS of COMPUT I NGDale & Lewis Chapter 2: Number Systems Final Exam ReviewNumbers in different bases: binary, decimal, hexadecimal Conversion: from other bases to decimal, from decimal to binary Math in different bases: addition in binary Key c
Wheaton College - CS - 106
The BASICS of COMPUT I NGSQL SyntaxSQL (Structured Query Language) is a powerful language for designing databases, modifying them, and, and drawing information out of them. It provides a standardized interface between applications and the underlying inf
Wheaton College - CS - 106
The BASICS of COMPUT I NGReview of Set Notation A = cfw_1,2,3,4 xA B = cfw_3,4,5,6 xASet TheoryU = cfw_1,2,3,4,5,6,7,8,9,10 1A 1B x is a member / is not a member of set A the intersection of sets A and B A B = cfw_x : x A and x B the union of sets A
Wheaton College - CS - 106
The BASICS of COMPUT I NGPages and FramesThe idea of paging is two-fold: Demand PagingAll programs currently running and all of their data must be in the main memory, from where the Control Unit can fetch the next instruction in order to execute it. H
Wheaton College - CS - 106
The BASICS OF COMPUT I NGRecording Your Alice ProgramsIf you are using Windows, there is a freeware screen recording software called CamStudio that will allow you to make movies of your Alice programs in action to share with your friends and family who
Wheaton College - CS - 215
AlgorithmsBig O: The Upper BoundBig O and its Cousinscg(n)f(n)n n0f(n) is O(g(n) ifthere is some real constant c > 0 and some integer constant n0 0 such that f(n) cg(n) for all n n0 Big Omega: The Lower Bound f(n) cg(n)n0nf(n) is (g(n) ifthere
Wheaton College - CS - 215
AlgorithmsAssignment #1 Homework: Big "Oh" Analysis Due Friday 2/3/061. (1 point) Bill has an algorithm, find2D, to find an element x in an n n array A. The algorithm find2D iterates over the rows of A, and calls the algorithms arrayFind, of Code Fragme
Wheaton College - CS - 215
AlgorithmsAN INTRODUCTION TO STL VECTORSLab #2 STL Vectors Tuesday 2/6/06As introduced in lecture, a vector can be seen mostly as a dynamic array. It is an ordered sequence, it can be randomly accessed (using the same kind of subscripts you are used to
Wheaton College - CS - 215
AlgorithmsOBJECTIVEAssignment #2 Program: Big O Due Thursday 2/9/05Write an program to prime numbers from 2 to n, where n is entered by the user at runtime. In addition to finding (and printing) the primes, you are going to analyze the amount of work y
Wheaton College - CS - 215
AlgorithmsLab #3 STL Lists and Recursion Tuesday 2/14/06AN INTRODUCTION TO STL LISTS URL for more information: http:/www.sgi.com/tech/stl/List.html The list class in the STL is an implementation of a doubly-linked list. Unlike with a vector, you cannot
Wheaton College - CS - 215
AlgorithmsRECURSIVE FUNCTIONS FOR EXPRESSING RUNNING TIMERecurrence RelationsThe idea behind a recurrence relation is to find a way to express the running time of an algorithm in terms of n, the size of its input: TA(n) = the time it takes algorithm A
Wheaton College - CS - 215
AlgorithmsThe recurrence relation was: T(1) = 0 T(n) = 2 T(n/2) + n Expand:Solution to Practice ProblemT(n) = 2 T(n/2) + n = 2 [ 2 T(n/4) + n/2 ] + n = 2 2 T(n/4) + n + n = 2 2 T(n/4) + 2n = 2 2 [ 2 T(n/8) + n/4 ] + 2n = 2 2 2 T(n/8) + 3n Guess: k expa
Wheaton College - CS - 215
AlgorithmsWork on this problem as practice for the first midterm.Practice ProblemThe recurrence relation that expresses the running time of most efficient sort algorithms is: T(1) = 0 T(n) = 2 T(n/2) + n For example, in merge sort, you first sort each
Wheaton College - CS - 215
AlgorithmsOBJECTIVEAssignment #3 Program: Recursion Due Friday 2/24/05Write a program to find all Inverted Repeats (IRs) of a given length L in an input file of nucleotides (DNA!) in the FASTA format. The length L is determined by the user at run-time;
Wheaton College - CS - 215
AlgorithmsLab #5 STL Stacks and Depth-First Search Tuesday 3/7/06AN INTRODUCTION TO STL STACKS URL for more information: http:/www.sgi.com/tech/stl/stack.html #include <stack> By this point, you know that most of the STL types work the same way as the o
Wheaton College - CS - 215
AlgorithmsDESCRIPTION Today you are going to implement a binary search tree. TO DO TODAY: 1. Download the starter files for this lab from the course website: node.h node.cpp tree.h 215 Lab 06 Starter.cppLab #6 Binary Search Trees Tuesday 3/21/062. Crea
Wheaton College - CS - 215
AlgorithmsAN INTRODUCTION TO STL SORTING ALGORITHMSLab #8 Sorting in the STL Tuesday 4/04/06One of the really cool things about the Standard Template Library is the series of generic algorithms that can be used on just about any one of the STL types. E
Wheaton College - CS - 215
AlgorithmsTHE RECURRENCE RELATION T(1) = 1 T(n) = 1 + 2 T(n/2) + n EXPAND T(n) T(n) T(n) = 1 + 2 [1 + 2 T(n/22) + n/2] + n = 3 + 22 T(n/22) + 2nThe Merge-Sort Running Time Proof2 expansions= 1 + 2 + 22 [1 + 2 T(n/23) + n/4] + 2n = 7 + 23 T(n/23) + 3n
Wheaton College - CS - 215
Algorithms: SupplementProving a Lower Bound for Comparison Algorithmsn1 2 4 8 16 32 64 128log n! log(n/2)^n/2)0 1 4.58 15.30 44.25 117.66 296.00 716.16 -0.5 0 2 8 24 64 160 384log(n^n) log(n/x)^n/x)0.00 2.00 8.00 24.00 64.00 160.00 384.00 896.00 -0
Wheaton College - CS - 215
AlgorithmsAssignment #5 Program: Game Trees Phase I Due Wednesday 3/29/06 Phase II Due Friday 4/7/06OBJECTIVE In this project, you will be designing a variant of the Checkers game in which the user plays against the computer. This is a very large and in
Wheaton College - CS - 215
AlgorithmsCOMPARING THE ALGORITHMSLab #9 Pattern Matching with Different Algorithms Tuesday 4/18/06In class we have studied the algorithms and implementation of three different pattern-matching algorithms: 1. Brute Force 2. Boyer-Moore 3. Knuth-Morris-
Wheaton College - CS - 215
AlgorithmsLab #10 Standard Tries Tuesday 4/25/06In this lab, you will implement a standard trie (with a couple of small modifications) in order to store all of the words of Moby Dick and determine the list of words (each with the count of how many times
Wheaton College - CS - 325
COMP 325: Database SystemsSQL Queries due Wed. Oct 4thHomework #3Please submit this homework in electronic format in an email. It is still due at the beginning of class on the due date. PART ONE: SQL AND THE CLASS DATABASE Connect to my MySQL server th
Wheaton College - CS - 325
COMP 325: Database SystemsHandout: Locking and BlockingLOCKINGStrict Two-Phase Locking (Strict 2PL) 1. if transaction T wants to read an object, first requests a shared lock on the object; if T wants to write an object, first requests an exclusive lock
Wheaton College - CS - 325
COMP 325: Database SystemsHandout: TransactionsACID ATOMICITY either all actions in the transaction are done, or none get done nothing is left halfdone CONSISTENCY the databases consistency must be preserved by the transaction if it is runningby itse
Wheaton College - CS - 325
COMP 325:DatabaseSystemsHandout:StaticHashingIndexesStatic HashingPros: Search: 1 disk I/O (after applying hash function, fetch the bucket) Insert: 2 disk I/Os (fetch the bucket, add record, write it back out) Delete: 2 disk I/Os (fetch the bucket, del
Wheaton College - CS - 325
COMP 325: Database Systems Handout: Comparing IndexesCost of OperationsScan Heap Files Sorted Files Clustered Files Heap File, Unclustered Tree Index Heap File, Unclustered Hash IndexEquality SearchRange SearchInsert RecordDeleteComparing Files an