Learning Objectives: General Description: DONE DONE Structure Chart

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

LAB 4.1 Relational Operators and the if Statement

Week 3: File I/O and Formatting 3.7 Formatting Output

Expressions, Input, Output and Data Type Conversions

Final Examination Semester 3 / Year 2010

The American University in Cairo Computer Science & Engineering Department CSCE Dr. KHALIL Exam II Spring 2010

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

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

The cin Object. cout << "Enter the length and the width of the rectangle? "; cin >> length >> width;

Sample Code: OUTPUT Daily Highs & Lows

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

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

CPE Summer 2015 Exam I (150 pts) June 18, 2015

CS 151 Review #3. // More than one variable can be defined // in a statement. Multiple variables are // separated by a comma.

Loops and Files. of do-while loop

Formatting outputs String data type Interactive inputs File manipulators. Access to a library that defines 3. instead, a library provides input

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

c++ keywords: ( all lowercase ) Note: cin and cout are NOT keywords.

Software Design & Programming I

C/C++ Programming Lecture 7 Name:

CPE 112 Spring 2015 Exam II (100 pts) March 4, Definition Matching (8 Points)

Lab 6. Review of Variables, Formatting & Loops By: Dr. John Abraham, Professor, UTPA

Piyush Kumar. input data. both cout and cin are data objects and are defined as classes ( type istream ) class

Definition Matching (10 Points)

Repetition Algorithms

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

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

TEST 1 CS 1410 Intro. To Computer Science Name KEY. October 13, 2010 Fall 2010

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

Finally, a receipt is printed on the screen and, after a pause, the process repeats for the next customer.

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

Arrays. Lecture 9 COP 3014 Fall October 16, 2017

CS 302: INTRODUCTION TO PROGRAMMING. Lectures 7&8

Functions that Return a Value. Approximate completion time Pre-lab Reading Assignment 20 min. 92

Fundamentals of Programming Session 8

Other Loop Options EXAMPLE

BRAZOSPORT COLLEGE LAKE JACKSON, TEXAS SYLLABUS COSC 1320: INTRODUCTION TO C++ PROGRAMMING COMPUTER TECHNOLOGY & OFFICE ADMINISTRATION DEPARTMENT

! A program is a set of instructions that the. ! It must be translated. ! Variable: portion of memory that stores a value. char

Using C++, design an Abstract Data Type class named MyGrades. The class must have the following private members :

Looping. Arizona State University 1

Overview. - General Data Types - Categories of Words. - Define Before Use. - The Three S s. - End of Statement - My First Program

Write a program that displays all the even integers between 1 and 100, inclusive

CSc 10200! Introduction to Computing. Lecture 4-5 Edgardo Molina Fall 2013 City College of New York

Name Section: M/W T/TH Number Definition Matching (6 Points)

Fundamentals of Programming CS-110. Lecture 2

1) What of the following sets of values for A, B, C, and D would cause the string "one" to be printed?

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

The American University in Cairo Computer Science & Engineering Department CSCE 106 Fundamentals of Computer Science

LECTURE 04 MAKING DECISIONS

CSc Introduction to Computing

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.

I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++

Lab ACN : C++ Programming Exercises

1. To introduce and allow students to work with arrays 2. To introduce the typedef statement 3. To work with and manipulate multidimensional arrays

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

int x = 5; double y = 3; // Integer division rounds the result down to the nearest whole number. cout << "1a: " << x / 3 << endl; //1

Programming. We will be introducing various new elements of Python and using them to solve increasingly interesting and complex problems.

EE 109 Lab 8a Conversion Experience

CSCD 255 HW 2. No string (char arrays) or any other kinds of array variables are allowed

Repetition Structures

I/O Streams and Standard I/O Devices (cont d.)

User Manual. Version 3.1. Copyright 2000 Academia Software Solutions All Rights Reserved

Outline. Review Choice Statements. Review Sequential Flow. Review Choice Before Loops. Review Choice After Loops

C++ PROGRAMMING. For Industrial And Electrical Engineering Instructor: Ruba A. Salamh

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

File I/O. File Names and Types. I/O Streams. Stream Extraction and Insertion. A file name should reflect its contents

Concepts Review. 2. A program is the implementation of an algorithm in a particular computer language, like C and C++.

Chapter 3 - Notes Input/Output

Faculty Portal and Course Management Training for Clarendon College Faculty

*Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

3.1. Chapter 3: The cin Object in Program 3-1. Displaying a Prompt 8/23/2014. The cin Object

Chapter 3: Expressions and Interactivity

LAB 7.1 Working with One-Dimensional Arrays

MATH NATION SECTION 9 H.M.H. RESOURCES

Chapter 5: Control Structures II (Repetition) Objectives (cont d.) Objectives. while Looping (Repetition) Structure. Why Is Repetition Needed?

LECTURE 5 Control Structures Part 2

Programming in C++ PART 2

CpSc 1111 Lab 9 2-D Arrays

Name Section: M/W T/TH Number Definition Matching (8 Points)

CS 302: Introduction to Programming in Java. Lecture 9

Engineering Problem Solving with C++, 3e Chapter 2 Test Bank

CS 2604 Minor Project 1 DRAFT Fall 2000

String Variables and Output/Input. Adding Strings and Literals to Your Programming Skills and output/input formatting

Q1: Multiple choice / 20 Q2: C input/output; operators / 40 Q3: Conditional statements / 40 TOTAL SCORE / 100 EXTRA CREDIT / 10

Class 2: Variables and Memory. Laura Marik Spring 2012 C++ Course Notes (Provided by Jason Minski)

CIS 130 Exam #2 Review Suggestions

LAB: FOR LOOPS IN C++

Exam 1. CSI 201: Computer Science 1 Fall 2018 Professors: Shaun Ramsey

During the first 2 weeks of class, all students in the course will take an in-lab programming exam. This is the Exam in Programming Proficiency.

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

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

Program Development. Java Program Statements. Design. Requirements. Testing. Implementation

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

Chapter 3: Expressions and Interactivity. Copyright 2012 Pearson Education, Inc. Thursday, October 9, 14

CS 215 Spring 2018 Project 2

Math 155. Measures of Central Tendency Section 3.1

LAB 11: METHODS. CPCS The Lab Note Lab 11 Page 1. Statement Purpose:

Variables, Data Types, and Arithmetic Expressions Learning Objectives:

Today in CS161. Lecture #12 Arrays. Learning about arrays. Examples. Graphical. Being able to store more than one item using a variable

Transcription:

1 CS 215 Fall 2017 Project 2: Grade Calculator Due October 9 @ midnight Version 2.1 Published 9/24 changes in Red [DUE DATE changed 10/3] Learning Objectives: - Developing a C++ program using the Procedure-Oriented Programming design paradigm. - Use of Functions - Use of Loops - Use of Decisions General Description: You are to write a program to assist a professor in entering scores and calculating the grades for a class of students. The program will first ask the user to enter general information about the class, including the number of tests, projects, labs and lecture attendance days so far for the semester. Next the program will process each student one at a time. The program asks the user to enter the student s name, or DONE to exit the program. For each student, the program will ask the user to enter the individual test, project, lab and attendance scores. It then calculates averages for the tests, projects, labs and attendance days entered, along with the overall percentage and letter grade. Finally, it prints a report for the student, then begins the next student. When the user enters DONE as the student name, no more student data is entered or processed. Instead, the program prints a report with the average overall percentage of the class, along with the name and overall percentage of the student with the highest percentage of all students entered. Structure Chart: this chart demonstrates the overall design that is to be used. Each box represents a function to be written. Specifications for each function are detailed below. A line between a higher-level function and a lower-level one indicates the higher-level function invokes the lower.

2 Specifications: Each function of the project is specified in detail below. Failure to follow the specifications, even if the program executes correctly, will result in deduction of points!. As always, if you would like to make a modification to the specifications, email the instructor and ask permission. You should use only the C++ language structures we have studied in class. In particular, do not use Classes or Arrays. Also, do not use any built-in C++ functions other than the following (again, you may ask for permission to use others): setw(), setprecision(), cin.ignore(), cin.getline(), to_string() printlogo: Prints a logo as shown in the examples below. Make up your own program name if you wish. Include your name in the logo. asknumber(): Given: - a question to ask the user - a maximum number Return: the valid number entered by the user. Prints the given question and allows the user to enter a number (which may have a decimal point). It should validate the user s input to be between zero and the maximum given, using the error message Invalid input. Enter a number between 0 and maximum The question should be left-justified and printed in a field width of 40. Example: when given Enter a score and a maximum of 4 Enter a score: -1 Invalid input. Enter a number between 0 and 4! Enter a score: 5 Invalid input. Enter a number between 0 and 4! Enter a score: 3.5 The 3.5 is returned. NOTE: when needed, use reserved words left and right for justification in a cout. cout << left << setw(10) << Num = << right setw(6) << 12.5; Prints: Num =...12.5 (where the dots are blanks) getclassnumbers(): Alters: the number of tests, projects, labs and attendance days. Invokes asknumber() with the following questions and maximums: Enter number of tests: 4 Enter number of projects: 5 Enter number of labs: 7 Enter number of attendance days: 50 getavg(): Given: the name of an item (ex: test, project, etc), the number of items, and the maximum score. Return: the average of the scores entered as a percentage. InvokingaskNumber() to get the individual scores, calculates a percentage of the scores entered based on the given maximum score. It should construct a prompt including the item number for each invocation of asknumber(). Example: given project, 3 and 50, it will invoke asknumber() 3 times with the prompt Enter item score n:

3 Some algebra will have to be done to correctly calculate the percentage. For example, projects are out of 50 points. But if someone has 3 projects, all 50 points, the percentage returned should be 100%, not 50%! Note: to concatenate an integer with a string, use the C++ built-in function to_string(). int age = 21; string name = Miguel ; string sentence = name + is age + to_string(age) +!\n ; cout << sentence; prints: Miguel is age 21! CalcPercentage(): Given: the test, project, lab and attendance averages Return: the calculated overall percentage Calculates the overall percentage using the following weights: Tests 40% Projects 30% Labs 20% Attendance 10% calcgrade(): Given: an overall percentage Return: a letter grade Use the standard 10-point scale for determining the letter grade: 90% or above A 80%-90% B 70%-80% C 60%-70% D Below 60% E printstudent(): Given: the name, all averages, percentage and grade Print the student report using the formatting shown in the examples below. Numbers should be rightjustified and printed with 1 digit past the decimal point. processstudent() Given: the name and number of tests, projects, labs and attendance days Return: the overall percentage calculated This is the middle manager function. It s job is to simply to coordinate the invocation of the functions detailed above, retrieving the results of functions and passing them to others. Invoke getavg() for the tests, projects and labs, using the following maximum number of points: Tests 100 Projects 50 Labs 10 For the attendance average, simply invoke asknumber(). Remember to calculate a percentage. (So if the number of attendance days is 15, and the student attended 15 days, the average should be 100%, not 15%!!).

Finally invoke the functions to calculate the overall percentage, the letter grade, and to print the student report. Return the calculated overall percentage. updatestats() Given: - the name and overall percentage of the student just processed. Alters: - the name and percentage of the top student so far in the class - the sum of the percentages of all students so far in the class - the number of students counted so far in the class At the end of execution, the program must print the name and percentage of the top student in the class, as well as the average overall percentage of all students in the class. The purpose of this function is to update the stats being maintained after one student has been processed. So, now there is one more student counted, and the given percentage is added to the sum of the percentages. If the percentage of the last student processed is higher than the top so far, then we have a new top student. printclassreport() Given: - the name and percentage of the top student - the number of students processed, and the sum of the percentages of all students processed. Calculates the average percentage of all students in the class and prints the class report as shown in the examples below. main() The primary job of main() is to coordinate the execution of the main functions, receiving the results and passing them to the next functions invoked as needed. Main is also responsible for the Sentinel Controlled Loop that stops the processing of students, and proceeds to the report. That is, main() asks the user to enter the student s name or DONE to quit. As usual, there should be a system pause at the end of main(). When asking for the student s name, the program should accept names including spaces at this point. Remember that: string name; cout << Enter name: ; cin >> name; will not accept anything with spaces. Instead, use the following: string name; cout << Enter name: ; cin.ignore(); // without this, the next command may not getline(cin,name); // work correctly. It won t STOP and WAIT 4

Example #1: 5

Example #2: error checking 6