Sonoma State University Computer Science Department CS 115 Fall 2010 Watts. Project 3 Part 1

Similar documents
The American University in Cairo Department of Computer Science & Engineering CSCI &09 Dr. KHALIL Exam-I Fall 2011

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7.

Midterm Practice Exam

Reading from and Writing to Files. Files (3.12) Steps to Using Files. Section 3.12 & 13.1 & Data stored in variables is temporary

ET 181. Purpose: The purpose of this lab is to become familiar with using arrays in C++.

CS 141, Introduction to Computer Science Fall Midterm Exam

while for do while ! set a counter variable to 0 ! increment it inside the loop (each iteration)

CSCE Practice Midterm. Data Types

Zimmer/Porter CSCI130 Fall Lab 6 Selection. 1. Begin by copying the file from my directory into your account (name it lab6.

CS 117 Programming II, Spring 2018 Dr. Ghriga. Midterm Exam Estimated Time: 2 hours. March 21, DUE DATE: March 28, 2018 at 12:00 PM

CS31 Discussion 1E. Jie(Jay) Wang Week1 Sept. 30

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

CS2255 HOMEWORK #1 Fall 2012

UEE1302(1066) F12: Introduction to Computers and Programming Function (II) - Parameter

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

Functions, Arrays & Structs

Review of Important Topics in CS1600. Functions Arrays C-strings

CMSC 202 Midterm Exam 1 Fall 2015

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.7. User Defined Functions II

CSCS 261 Programming Concepts Exam 1 Fall EXAM 1 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

Due Date: See Blackboard

VARIABLES & ASSIGNMENTS

a. a * c - 10 = b. a % b + (a * d) + 7 =

Review: Exam 1. Your First C++ Program. Declaration Statements. Tells the compiler. Examples of declaration statements

Note: The buy help from the TA for points will apply on this exam as well, so please read that carefully.

CSE030 Fall 2012 Final Exam Friday, December 14, PM

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Dr. Khalil Exam II Fall 2011

Introduction to Computer Science Midterm 3 Fall, Points

Week 3. Function Definitions. Example: Function. Function Call, Return Statement. Functions & Arrays. Gaddis: Chapters 6 and 7. CS 5301 Spring 2018

Multiple Choice (Questions 1 14) 28 Points Select all correct answers (multiple correct answers are possible)

CSCE Practice Midterm. Data Types

FORM 1 (Please put your name and section number (001/10am or 002/2pm) on the scantron!!!!) CS 161 Exam II: True (A)/False(B) (2 pts each):

LAB 4.1 Relational Operators and the if Statement

Due Date: See Blackboard

Topics. Functions. Functions

7 Arrays. 7.1 Arrays Hold Multiple Values TOPICS. CONCEPT: An array allows you to store and work with multiple values of the same data type.

Computer Department. Question (1): State whether each of the following is true or false. Question (2): Select the correct answer from the following:

CS 580 FINAL EXAM. Fall April 29, 2014

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Exam 2. CSI 201: Computer Science 1 Fall 2016 Professors: Shaun Ramsey and Kyle Wilson. Question Points Score Total: 80

1- Write a single C++ statement that: A. Calculates the sum of the two integrates 11 and 12 and outputs the sum to the consol.

FORM 2 (Please put your name and form # on the scantron!!!!)

The American University in Cairo Department of Computer Science & Engineeringt CSCI &09 Dr. KHALIL Exam-I Fall 2009

CS 31 Discussion 1A, Week 4. Zengwen Yuan (zyuan [at] cs.ucla.edu) Humanities A65, Friday 10:00 11:50 a.m.

Total 100. The American University in Cairo Computer Science & Engineering Department CSCE 106. Instructor: Final Exam Fall Section No.

CS Introduction to Programming Midterm Exam #2 - Prof. Reed Fall 2015

CS2141 Software Development using C/C++ C++ Basics

Due Date: See Blackboard

Lecture 12. Monday, February 7 CS 215 Fundamentals of Programming II - Lecture 12 1

C++ For Science and Engineering Lecture 2

Exercise 1.1 Hello world

Do not turn to the next page until the start of the exam.

You must pass the final exam to pass the course.

Lecture 7. Log into Linux New documents posted to course webpage

Agenda. The main body and cout. Fundamental data types. Declarations and definitions. Control structures

CSCS 261 Programming Concepts Exam 2 Fall EXAM 2 VERSION 1 Fall Points. Absolutely no electronic devices may be used during this exam.

CS 1337 Computer Science II Page 1

! Pass by value: when an argument is passed to a. ! It is implemented using variable initialization. ! Changes to the parameter in the function body

System Design and Programming II

Object Oriented Design

More Flow Control Functions in C++ CS 16: Solving Problems with Computers I Lecture #4

Sample Final Exam. 1) (24 points) Show what is printed by the following segments of code (assume all appropriate header files, etc.

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Algorithms for Arrays Vectors Pointers CS 16: Solving Problems with Computers I Lecture #14

CS16 Final Exam E03, 10S, Phill Conrad, UC Santa Barbara Wednesday, 06/09/2010

Week 4 EECS 183 MAXIM ALEKSA. maximal.io

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

CS 150 Lab 10 Functions and Random Numbers

CSCI 111 First Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, October 18, 2017

CS 240 Data Structure Spring 2018 Exam I 03/01/2018

DHA Suffa University CS 103 Object Oriented Programming Fall 2015 Lab #01: Introduction to C++

Chapter 6: User-Defined Functions. Objectives (cont d.) Objectives. Introduction. Predefined Functions 12/2/2016

CSC 126 FINAL EXAMINATION Spring Total Possible TOTAL 100

switch case Logic Syntax Basics Functionality Rules Nested switch switch case Comp Sci 1570 Introduction to C++

Arrays. What if you have a 1000 line file? Arrays

CSCI 111 Second Midterm Exam Fall Solutions 09.00am 09.50am, Wednesday, November 29, 2017

Designing Loops and General Debug Pre-Defined Functions in C++ CS 16: Solving Problems with Computers I Lecture #6

CS 115 Exam 3, Spring 2011

Due Date: See Blackboard

Functions, Arrays & Structs

Outline. Review of Last Week II. Review of Last Week. Computer Memory. Review Variables and Memory. February 7, Data Types

pointers + memory double x; string a; int x; main overhead int y; main overhead

Tutorial 13 Salary Survey Application: Introducing One- Dimensional Arrays

CS 105 Lecture 5 Logical Operators; Switch Statement. Wed, Feb 16, 2011, 5:11 pm

Multiple Choice Questions (20 questions * 6 points per question = 120 points)

University of Maryland Baltimore County. CMSC 202 Computer Science II. Fall Mid-Term Exam. Sections

Elements of C in C++ data types if else statement for loops. random numbers rolling a die

Lab 2.1: Fixing a C++ program

LAB 7.1 Working with One-Dimensional Arrays

Functions. CS111 Lab Queens College, CUNY Instructor: Kent Chin

Introduction to Lab Sessions

Lab 2: Pointers. //declare a pointer variable ptr1 pointing to x. //change the value of x to 10 through ptr1

CS150 Assignment 7 Cryptography

GE U111 Engineering Problem Solving & Computation Lecture 6 February 2, 2004

CS261: HOMEWORK 2 Due 04/13/2012, at 2pm

Project 1. due date Sunday July 8, 2018, 12:00 noon

EAS230: Programming for Engineers Lab 1 Fall 2004

Ch 5-2. Arrays Part 2

Makefiles Makefiles should begin with a comment section of the following form and with the following information filled in:

Transcription:

Sonoma State University Computer Science Department CS 115 Fall 2010 Watts Project 3 Part 1 For this part of the project you will be modifying one of the programs you submitted for Lab 8 to calculate your CS 115 percentage and letter grade. Specifications: 1. Create a copy of your Lab8e.cpp program for Project 3 cd cs115 mkdir Proj3 cd Proj3 cp../lab8/lab8e.cpp Proj3.cpp 2. Currently the program calculates a single percentage using the formula Percentage = 100 * (the sum of the actual scores) / (the sum of the possible scores) In CS 115, a separate percentage is calculated for your labs and homeworks (LH%), your projects (P%), and your quizzes and exams (QE%). The overall percentage is calculated using the formula Percentage = 0.2 * LH% + 0.3 * P% + 0.5 * QE% 3. Modify the function ComputePctScore as follows: a. Add a new character variable to contain the assignment type called atype; b. Modify the input statement to read in atype before it reads in earned and possible. c. Change the name of the variable total_earned to LH_earned and the name of the variable total_possible to LH_possible. Add similar variables for the projects (P) and the Quizzes and exams (QE). d. If atype is L or H, add the value of earned to LH_earned and the value of possible to LH_possible. Similarly, if atype is P add earned and possible to the appropriate variables and if type is Q or E add earned and possible to the appropriate variables. e. After you have read all of the assignment information from the file, calculate the individual percentage values for LH, P, and QE. f. Calculate and return the overall percentage. 4. The input file will contain a line for each assignment. Each assignment line will have the format: character_assignment_type integer_earned integer_possible 5. Modify the main function so tht it prints the overall average and a corresponding letter grade as indicated in the table below: Score Range Letter grade 90 100% A 80 89% B 70 79% C 60-69% D 0 59% F 6. Test input files called p3scores1.in and p3scores2.in can be copied from the cs115pickup folder: cp ~tiawatts/cs115pickup/p3scores*.in.

Date Due: Sunday, 31 October 2010, 11:59 pm. To Turn In: A well documented and formatted C++ program and a text description file. The C++ program should be called lastfp3.cpp and the text description file should be called lastfp3.txt. The text file should describe the issues you encountered while writing the program. Sample Input File 10 L 9 10 L 8 10 H 10 10 L 10 10 P 55 50 Q 7 10 E 85 100 P 48 50 L 10 10 H 8 10 Corresponding Output Please enter the name of the file: p3scores1.in Your percent is 91.0515% Your grade is A. Sample Input File 10 L 7 10 L 8 10 H 6 10 L 10 10 P 45 50 Q 7 10 E 75 100 P 38 50 L 10 10 H 8 10 Corresponding Output Please enter the name of the file: p3scores2.in Your percent is 78.5061% Your grade is C.

Sonoma State University Computer Science Department CS 115 Fall 2010 Watts Project 3 Part 2 For this part of the project you will be modifying the program you submitted for Project 3 Part1. Specifications: 1. Create a copy of the file you turned for project 3. 2. Modify the program to store the assignment information in arrays. You will need 5 arrays: char atype [MAX]; int earned [MAX]; int possible [MAX]; string date [MAX]; string name [MAX]; where MAX is defined at the beginning of your program as a constant integer: const int MAX = 100; 3. Modify the program to read the date and name of the assignment. a. The date of the assignment will be in the format yyyy/mm/dd and will follow the possible points for the assignment. There will be one space between the possible points and the date. b. The name of the will follow the date for the assignment. There will be 1 space between the date and the name of the assignment. There will be nothing on the input line after the name of the assignment. The name of the assignment may contain more than 1 word. 4. Modify the program to read from the input file until it reaches the end of the file. 5. Modify the program to count the number of assignments in the file. Modify the program to print the number of assignments. 6. Modify the program to print information about the assignments after it prints the number of assignments. 7. Modify the program to print the percentage grades for each of the 3 categories (Labs and Homeworks, Projects, Quizzes and Exams). 8. A test input file called p3scores3.in can be copied from the cs115pickup folder: cp ~tiawatts/cs115pickup/p3scores3.in. 9. Here are some sample prototypes and a version of main which uses these prototypes. using namespace std;

const int MAX = 100; // Function to open file and read data into arrays. // Will return numbor of assignments (-1 if the file cannot be read) int InputScores(ifstream& input, char T[], int E[], int P[], string D[], string N[]); // Function to print data from the arrays. void PrintScores (int numscores, char T[], int E[], int P[], string D[], string N[]); // Function to calculate and return the overall percentage score using the // data in the arrays. Will also print the percentage score for each category. float ComputePctScore(int numscores, char T[], int E[], int P[], string D[], string N[]); // Function to determine the letter grade for the overall percent score. char DetermineGrade (float pct); int main() { ifstream inputfile; int numscores; char atype [MAX]; int earned [MAX]; int possible [MAX]; string date [MAX]; string name [MAX]; // Variable for input file // Number of scores stored in the input file // Array to hold assignment types // Array to hold assignment earned scores // Array to hold assignment possible scores // Array to hold assignment dates // Array to hold assignment names // Call a function to open the input file and the data into the arrays. numscores = InputScores(inputFile, atype, earned, possible, date, name); // If there was an error reading the file, output a message and exit. if (numscores == -1) { cout << "Could not read input file\n"; exit (1); } cout << "There are " << numscores << " assignments in the file\n"; // Call function to print assignment data from the arrays. PrintScores(numScores, atype, earned, possible, date, name); // Call a function to compute the overall percentage score. // This function will also print out the percent score for each category. float percent = ComputePctScore(numScores, atype, earned, possible, date, name); cout << "Your percent is " << percent << "%\n"; // Call function to determine letter grade for percent score. cout << "Your grade is " << DetermineGrade (percent) << endl; // Close the input file inputfile.close(); } return 0;

Date Due: Wednesday, 10 November 2010, 11:59 pm (Please DO NOT submit before 1 November 2010). To Turn In: A well documented and formatted C++ program and a text description file. The C++ program should be called lastfp3-2.cpp and the text description file should be called lastfp3.txt. The text file should describe the issues you encountered while writing the program.; this file should include issues from Project 3 Parts 1 & 2. Sample Input File L 5 5 2010/08/25 Lab 2 Program E 94 100 2010/10/13 Exam 1 Corresponding Output Please enter the name of the file: p3scores3.in There are 12 assignments in the file L 5 5 2010/08/25 Lab 2 Program E 94 100 2010/10/13 Exam 1 Your Lab and Homework percent is 80% Your Project percent is 103% Your Quiz and Exam percent is 94.5455% Your percent is 94.1727% Your grade is A.

Sonoma State University Computer Science Department CS 115 Fall 2010 Watts Project 3 Part 3 For this part of the project you will be modifying the program you submitted for Project 3 Part 2. This is the final part of this project. Specifications: 1. Create a copy of the file you turned for project 3 part 2. 2. Modify your program to expect a type of T for an exam instead of a type of E. 3. Add several new prototypes to your program: // Function to swap two integer values void Swap (int & a, int & b); // Function to swap two string values void Swap (string & a, string & b); // Function to swap two character values void Swap (char & a, char & b); // Fuction to sort the parallel data arrays void Sort (int numscores, char T[], int E[], int P[], string D[], string N[]); // Fuction to print a formatted report of the assignments and percentage grades void PrintReport (int numscores, char T[], int E[], int P[], string D[], string N[]); 4. Create stubbs at the end of the file for each of your new functions. 5. Implement the Swap and Sort functions as described in class. 6. Add a call to the Sort function and another call to the PrintScores function in your main function after the existing call to the PrintScores function: // Call function to print assignment data from the arrays. PrintScores(numScores, atype, earned, possible, date, name); cout << endl; // Call function to sort the assignment data in the arrays. Sort(numScores, atype, earned, possible, date, name); // Call function to print assignment data from the sorted arrays. PrintScores(numScores, atype, earned, possible, date, name); cout << endl; 7. Copy the file p3scores3.txt from ~tiawatts/cs115pickup. Compile and execute your program. Make sure that the assignments are sorted, first by type and then by date within type: Please enter the name of the file: p3scores3.txt There are 12 assignments in the file

L 5 5 2010/08/25 Lab 2 Program T 94 100 2010/10/13 Exam 1 L 5 5 2010/08/25 Lab 2 Program T 94 100 2010/10/13 Exam 1 Your Lab and Homework percent is 80% Your Project percent is 103% Your Quiz and Exam percent is 94.5455% Your percent is 94.1727% Your grade is A 8. Modify the function PrintReport to print a report in the following format for the sorted assignments: Type Earned Possible Date Assignment Name L 5 5 2010/08/25 Lab 2 Program 32 40 Your Lab and Homework percent is 80% Type Earned Possible Date Assignment Name 103 100 Your Project percent is 103% Type Earned Possible Date Assignment Name T 94 100 2010/10/13 Exam 1 104 110 Your Quiz and Exam percent is 94.5455% Your overall percent is 94.1727% Your grade is A

12. Modify the main function of your program to call the Sort and the PrintReport functions instead of PrintScores, ComputePctGrade, and DetermineGrade. Your final main function should look like: int main() { ifstream inputfile; int numscores; char atype [MAX]; int earned [MAX]; int possible [MAX]; string date [MAX]; string name [MAX]; // Variable for input file // Number of scores stored in the input file // Array to hold assignment types // Array to hold assignment earned scores // Array to hold assignment possible scores // Array to hold assignment dates // Array to hold assignment names // Call a function to open the input file and the data into the arrays. numscores = InputScores(inputFile, atype, earned, possible, date, name); // If there was an error reading the file, output a message and exit. if (numscores == -1) { cout << "Could not read input file\n"; exit (1); } // Call function to sort assignment data in the arrays. Sort(numScores, atype, earned, possible, date, name); // Call function to print formatted report of the data in the arrays. PrintReport(numScores, atype, earned, possible, date, name); // Close the input file inputfile.close(); } return 0; Date Due: Wednesday, 1 December 2010, 11:59 pm (Please DO NOT submit before 20 November 2010). To Turn In: A well documented and formatted C++ program and a text description file. The C++ program should be called lastfp3-3.cpp and the text description file should be called lastfp3.txt. The text file should describe the issues you encountered while writing the program; this file should include issues from Project 3 Parts 1, 2 & 3.