Honors Introduction to C (COP 3223H) Program 5 Pizza Shack Inventory and Finances

Similar documents
Fall 2016 COP 3223H Program #4: Ads, flags and debates! Due date: Please consult WebCourses for your section

Assignment 5 Files, Linked Lists, and Binary Search Trees

CS 1428 Programming Assignment 2 Due Wednesday September 19 th :15 am Section 3 3:45 pm Section 4

Chapter 3 Lab Decision Structures

Linear Functions. Connection to AP*: AP Calculus Topic: Analysis of Functions

Task #1 The if Statement, Comparing Strings, and Flags

WEBSTORE: TIPS & TRICKS GAME SHOW. Erin Motett

CS 2316 Homework 9b GT Thrift Shop Due: Wednesday, April 20 th, before 11:55 PM Out of 100 points. Premise

Laboratory 2: Programming Basics and Variables. Lecture notes: 1. A quick review of hello_comment.c 2. Some useful information

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

Expressions, Input, Output and Data Type Conversions

Ex: If you use a program to record sales, you will want to remember data:

Latest R Systems Placement Test Questions

Assignment 1 Expressions Data Types Formatted Printing Variables Scanning CSC 123 Fall 2018 Answer Sheet Short Answers

DM 505 Database Design and Programming. Spring 2012 Project. Department of Mathematics and Computer Science University of Southern Denmark

Procedures, Parameters, Values and Variables. Steven R. Bagley

King Abdulaziz University Faculty of Computing and Information Technology Computer Science Department

2. Numbers In, Numbers Out

Data Types and Variables in C language

ICT WORKSHEET GRADE 9 TERM1 EXAMINATION

Clearnine Cart Pricing and Features

Merging Data From Spreadsheets to or Documents

Variables Data types Variable I/O. C introduction. Variables. Variables 1 / 14

COMS Spring Homework 3

Lab 3 - Pizza. Purpose. Assignment

1. HotDog 판매량출력프로그램. numsold = newnumsold; ID = newid; HotDogStand(); HotDogStand(int newid, int newnnumsold); return ID; void SetID(int newid);

Math 3A Meadows or Malls? Review

CS32 Discussion Sec.on 1B Week 2. TA: Zhou Ren

FOM 11 Practice Test Name: Ch. 6 Systems of Inequalities Block:

COP 5725 Fall Hospital System Database and Data Interface. Term Project

Introduction to Java Unit 1. Using BlueJ to Write Programs

Spring 2002 Page 1 of 8 READ THIS NOW!

Sales Station Mobile User Guide

Chapter 2 THE STRUCTURE OF C LANGUAGE

REVIEW OF 6 TH GRADE

CS 111X - Fall Test 1

hp calculators HP 20b Using Memories to Solve Problems Constant memory and planning Memory registers Other memory locations

Homework 5: Conditionals and Loops in C

2. Numbers In, Numbers Out

DIVINE SAVIOR ACADEMY LUNCH PROGRAM

a. Establish a one-to-many relationship between the Items and Inventory tables.

gcc o driver std=c99 -Wall driver.c bigmesa.c

Data Types & Variables

IT 1033: Fundamentals of Programming Data types & variables

Vingd API for PHP Documentation

Course Outline. TERM EFFECTIVE: Spring 2016 CURRICULUM APPROVAL DATE: 10/12/2015

LESSON 1: INTRODUCTION TO COUNTING

Additional Questions

Differentiate Between Keywords and Identifiers

AP Statistics Summer Review Packet

JavaScript Activites

Answer Key a reference section in the back of the Student Reference Book (SRB) that gives answers to sample problems

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

Computer Science 1 Program 4 TA Lab (Stacks & Queues) Assigned: 3/2/11 Due: 3/23/11 (Wednesday) at 11:55pm (WebCourses time)

EECS 211 Lab 6. Classes and Abstractation Winter Getting the code. Encapsulation and Abstraction. Classes

Genesis Advantage. Version 7

Complete On-Demand Clone Documentation

Name: Date: Class Period: Algebra 2 Honors Semester 1 final Exam Review Part 2

COMP105 Assignment 2: Higher order functions

Ordering through Gateway for MCDB Labs

Fundamentals of Programming Session 8

Foundation Exam - Sample Problems for New Topics

ediningexpress Owners Manual User Guide Copyright All Rights Reserved.

Your Real Estate & Strata Management Customer Communication Requirements Issues Solved

1. What type of error produces incorrect results but does not prevent the program from running? a. syntax b. logic c. grammatical d.

Presented By : Gaurav Juneja

DECLARATIONS. Character Set, Keywords, Identifiers, Constants, Variables. Designed by Parul Khurana, LIECA.

CSE 1325 Project Description

Logical Connectives. All kittens are cute. ; I like pizza. ; The sky is blue. ; Triangles have three sides.

C: How to Program. Week /Mar/05

CS 361 Computer Systems Fall 2017 Homework Assignment 1 Linking - From Source Code to Executable Binary

Department of Computer Science & Engineering Indian Institute of Technology Kharagpur. Practice Sheet #04

CS 1803 Individual Homework 1 Python Practice Due: Wednesday, January 26th, before 6 PM Out of 100 points

Fall CSEE W4119 Computer Networks Programming Assignment 1 - Simple Online Bidding System

conditional statements

Assignment 1 Feedback and Assignment 2

Basic program The following is a basic program in C++; Basic C++ Source Code Compiler Object Code Linker (with libraries) Executable

CHAPTER 1.2 INTRODUCTION TO C++ PROGRAMMING. Dr. Shady Yehia Elmashad

QBSalesData Version Release Notes

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

CS Spring 05 - MidTerm

SELECTION IDIOMS. Here is a summary of appropriate selection idioms: Selection Idioms. Action Condition Construct to Use. Sequential if statements

PA3: Violet's Vending Venture (Version 3.0)

Unit 3, Activity 1, Vocabulary Self-Awareness Chart

FOOD-TRAK System Version 4.64 ReadMe

CS 1301 Pair Homework 2 Conversions Due: Monday January 27th, 2014, before 11:55pm Out of 100 points Files to submit: hw2.py

AP Statistics Summer Math Packet

Menu Profitbuilder Pro Online. Creating Simple Menu Items. Covered in this tutorial:

KIS Kindergarten Integrated Platform Start-up Guide for epos

Chapter 2 - Introduction to C Programming

2018 Fall Sale Juliette Checklist of Important Dates

Lab Exam 1 D [1 mark] Give an example of a sample input which would make the function

2016 Autosoft, Inc. All rights reserved.

printf( Please enter another number: ); scanf( %d, &num2);

Department of Electrical Engineering and Computer Sciences Spring 2013 Instructor: Dr. Dan Garcia CS61C Midterm

BIS1523 Homework Assignments 2.1

Understand Computer Storage and Data Types

EBIONETWORXS FLASH TRAINING MANUAL

C 1. Recap: Finger Table. CSE 486/586 Distributed Systems Remote Procedure Call. Chord: Node Joins and Leaves. Recall? Socket API

CS 111X - Fall Test 1 - KEY KEY KEY KEY KEY KEY KEY

Transcription:

Honors Introduction to C (COP 3223H) Program 5 Pizza Shack Inventory and Finances Objective To give students practice writing a program with structs, functions and arrays, all interleaved. The Problem: Pizza Shack Inventory and Finances Pizza Shack periodically orders ingredients for their pizza. When pizza orders come in, they can only fill the order if they have enough of each ingredient for that particular order. If they don t, then they don t fill the order at all. In addition, for each order that is filled, Pizza Shack gets money, which they can then use to buy more ingredients. Obviously, the prices of the pizzas are more than the cost that the store pays for the raw ingredients; this is how Pizza Shack makes money!!! In this program, you ll use structs to keep track of Pizza Shack s inventory, fill orders for pizzas, and keep track of the amount of money in the bank account. (We assume that the only transactions with the bank account are to take money from the account to buy ingredients and to put money into the account from sales.) Since Pizza Shack processes many orders, you will read in all of the information about buying ingredients and processing orders from an input file. Pricing Details Each pizza has a base cost depending on its size as follows: Small $7 Medium $10 Large $13 XLarge $16 Then, the first two toppings beyond the three required ingredients: dough, sauce and cheese, are free. Each additional topping is 50 cents. Thus, if a large pizza has 8 total ingredients (3 required ingredients plus 5 toppings), the price a customer pays for it is $13.00 + $1.50 = $14.50. A pizza is sold only if enough of each ingredient is available. Buying Ingredient Details Each time an opportunity to buy ingredients comes up, they might be at a slightly different price. Also, to keep things simple each sale is fixed. Thus, you can t buy any number of pepperonis, you either have to buy the entire order or none of it. You will buy any order as long as you have the funds to do so. An order will be specified by the name of the ingredient, the number of units of it for the sale and the price per unit of the ingredient, for that purchase. Each ingredient name will be a unique lowercase identifier of 19 or fewer letters.

Individual Pizza Details Each pizza that customers can buy has a name and a size. These combinations will be unique. In addition, each pizza will have a number of ingredients to make it, as well as list of those ingredients. Each ingredient will be a name and a quantity of number of units of that ingredient necessary to make that specific pizza. (For example, an XLarge pepperoni pizza might have 12 units of pepperoni while a Small pepperoni pizza might only have 5 units of pepperoni on it.) There will be no more than 100 pizza types total. Implementation Requirements You must use the following structs and constants: #define MAXLEN 20 #define MAXPIZZATYPES 100 #define MAXINGREDIENTS 20 const float PRICES[4] = {7.00, 10.00, 13.00, 16.00}; typedef struct ingredient { char name[maxlen]; int quantity; } Ingredient; typedef struct pizza { char name[maxlen]; int numingredients; Ingredient ingredientlist[maxingredients]; int size; } Pizza; Input File Specification (pizzasim.txt) The first line of the file contains a single positive integer, numpizzas (numpizzas 100), indicating the number of different pizza types. The descriptions of the pizzas will follow. The first line of the description for each pizza will contain the name of the pizza (19 or fewer lowercase letters), followed by a space, followed by the size of the pizza (an integer 0, 1, 2 or 3, indicating small, medium, large and xlarge, respectively), followed by a space, followed by the number of ingredients, numingredients (3 numingredients 20) in the pizza. The following numingredients lines will each contain information about the ingredients necessary to build this type of pizza. Each of these lines will have the name of the ingredient (19 or fewer lowercase letters), followed by a space, followed by the number of units of that ingredient needed for the pizza. After the pizza descriptions, the next line will contain a single floating point number indicating the number of dollars currently in the bank account. (We assume that we start with no supplies.)

This will be followed by a line with a single positive integer, numactions (numactions 100000), indicating the number of actions to process. Each process will be described in sequence, on a single line. Each process will either be buying an ingredient OR selling a particular number of a single type of pizza. The format for a line describing a purchase of an ingredient is as follows: The line will start with the key word BUY followed by a space, followed by the name of the ingredient (19 or fewer lowercase letters), followed by a space, followed by a positive integer representing the number of units of that ingredient, followed by a space, ending with a positive floating point number representing the total cost of the order. The input file will never require buying more than 20 different types of ingredients for the whole simulation. The format for a line describing the potential sale of a pizza is as follows: The line will start with the key word SELL followed by a space, followed by the name of the pizza (19 or fewer lowercase letters), followed by a space, followed by a positive integer representing the number of that pizza for the order. Output Specification (output to the screen) For each of the actions in the input file, output a single line corresponding to the action. For BUY actions, if enough money isn t available for the purchase, output the following line: BUY could not be executed due to insufficient funds. Otherwise, output a line with the following format: Bought X units of Y. Now have Z units of Y in stock. where X is the number of units of ingredient Y purchased, and Z is the number of units of ingredient Y in inventory after the purchase. For SELL actions, if all the requisite ingredients are not available to create the pizza(s) for the order, output the following line: SELL could not be executed due to insufficient ingredients. Otherwise, output a line with the following format: Sold X Y pizzas for $Z.

where X is the quantity of pizzas sold, Y is the name of the pizza and Z is the total money in dollars collected for the sale based on the pricing scheme previously described printed to two decimal places. After outputting a line for each action, output a line indicating the amount of money left at the end of the simulation using the following format: $X left after the end of the simulation. where X is the number of dollars left printed to 2 decimal places. Sample Input File 2 usual 1 3 dough 10 sauce 5 cheese 4 bigmeaty 3 6 dough 16 sauce 10 cheese 8 sausage 12 pepperoni 15 ham 14 1000.00 11 BUY pepperoni 1000 25.00 BUY sausage 200 20.00 BUY cheese 500 100.00 BUY sauce 500 50.00 BUY dough 1000 20.00 BUY sausage 10000 1000.00 BUY pepperoni 100 3.00 BUY ham 1000 20.00 SELL usual 20 SELL bigmeaty 5 SELL bigmeaty 12 Sample Output Bought 1000 units of pepperoni. Now have 1000 units of pepperoni in stock. Bought 200 units of sausage. Now have 200 units of sausage in stock. Bought 500 units of cheese. Now have 500 units of cheese in stock. Bought 500 units of sauce. Now have 500 units of sauce in stock. Bought 1000 units of dough. Now have 1000 units of dough in stock. BUY could not be executed due to insufficient funds. Bought 100 units of pepperoni. Now have 1100 units of pepperoni in stock. Bought 1000 units of ham. Now have 1000 units of ham in stock. Sold 20 usual pizzas for $200.00. Sold 5 bigmeaty pizzas for $82.50. SELL could not be executed due to insufficient ingredients. $1044.50 left after the end of the simulation. Note: More substantial examples will be posted online at a later date. NOTE: PLEASE TRY TO MATCH THE OUTPUT GIVE EXACTLY, AS GRADING WILL BE BASED ON PERFECTLY MATCHING MY OUTPUT.

Restrictions Name the file you create and turn in pizzasim.c. Although you may use other compilers, your program must compile and run using gcc in Code::Blocks. Your program should include a header comment with the following information: your name, course number, section number, assignment title, and date. You should also include comments throughout your code, when appropriate. If you have any questions about this, please see a TA. Deliverables A single source file named pizzasim.c turned in through WebCourses.