Honors Computer Science C++ Mr. Clausen Program 6A, 6B, 6C, & 6G

Similar documents
Introduction To Computer Programming C++ Mr. Clausen Program C11A, C11B

Honors Computer Science C++ Mr. Clausen Program 4A, 4B, 4C, 4D, 4G

Honors Computer Science C++ Mr. Clausen Program 4A, 4B, 4C (4D, 4G)

Honors Computer Science Python Mr. Clausen Program 7A, 7B

Honors Computer Science C++ Mr. Clausen Program 3A, 3B, 3C

WARM UP LESSONS BARE BASICS

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

CSCI 111 Midterm 1, version A Exam Fall Solutions 09.00am 09.50am, Tuesday, October 13, 2015

Chapter 4 Computer Science with C++ Name: Review Worksheet A Mr. Ferwerda

LAB: INTRODUCTION TO FUNCTIONS IN C++

Chapter 4: Subprograms Functions for Problem Solving. Mr. Dave Clausen La Cañada High School

Chapter 7 Functions. As an example, let us write some code to make a virtual cup of coffee.

CAMBRIDGE SCHOOL, NOIDA ASSIGNMENT 1, TOPIC: C++ PROGRAMMING CLASS VIII, COMPUTER SCIENCE

AP Computer Science Java Mr. Clausen Program 6A, 6B

Chapter 4: Subprograms Functions for Problem Solving. Mr. Dave Clausen La Cañada High School

CHAPTER 4 FUNCTIONS. Dr. Shady Yehia Elmashad

CS201 - Introduction to Programming FAQs By

Mathematics 350 Section 6.3 Introduction to Fractals

Spring CS Homework 3 p. 1. CS Homework 3

Understanding main() function Input/Output Streams

Introduction to Flash - Creating a Motion Tween

CpSc 1011 Lab 4 Formatting and Flow Control Windchill Temps

5th Grade Mathematics Essential Standards

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.1

Archdiocese of Washington Catholic Schools Academic Standards Mathematics

Object Oriented Programming Using C++ Mathematics & Computing IET, Katunayake

Performance Level Descriptors. Mathematics

1 Getting started with Processing

Introduction to Java Unit 1. Using BlueJ to Write Programs

Computer Programming, I. Laboratory Manual. Experiment #2. Elementary Programming

Math Analysis Chapter 1 Notes: Functions and Graphs

Independent Representation

Expressions and Casting

Lesson 6 Adding Graphics

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

I can use number bonds and matching subtraction facts up to 20.

Other Loop Options EXAMPLE

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

Integer Operations. Summer Packet 7 th into 8 th grade 1. Name = = = = = 6.

Math Analysis Chapter 1 Notes: Functions and Graphs

Arrays in C++ Instructor: Andy Abreu

AP Computer Science Unit 1. Writing Programs Using BlueJ

CHAPTER 4 FUNCTIONS. Dr. Shady Yehia Elmashad

About Finish Line Mathematics 5

WT I (SET-I) Date: Class XI Sec. Time: 1 Hr. 10 min. Computer Science M.M.: 30

Paint Tutorial (Project #14a)

Unit 3, Lesson 2 Data Types, Arithmetic,Variables, Input, Constants, & Library Functions. Mr. Dave Clausen La Cañada High School

A Freshman C++ Programming Course

Chapter 3 Syntax, Errors, and Debugging. Fundamentals of Java

Seventh Grade Mathematics Content Standards and Objectives

Lecture 3. Input and Output. Review from last week. Variable - place to store data in memory. identified by a name should be meaningful Has a type-

Prentice Hall Mathematics: Course Correlated to: Ohio Academic Content Standards for Mathematics (Grade 7)

C++ Basic Elements of COMPUTER PROGRAMMING. Special symbols include: Word symbols. Objectives. Programming. Symbols. Symbols.

Objective- Students will be able to use the Order of Operations to evaluate algebraic expressions. Evaluating Algebraic Expressions

Pre-Algebra Notes Unit One: Variables, Expressions, and Integers

Object Oriented Programming 2012

Central Valley School District Math Curriculum Map Grade 8. August - September

Introduction of C++ OOP forces us to think in terms of object and the interaction between objects.

KINDERGARTEN MATH STANDARDS BASED RUBRIC NUMBER SENSE Essential Standard: 1.0 STUDENTS UNDERSTAND THE RELATIONSHIP BETWEEN NUMBERS AND QUANTITIES.

CIS 110 Introduction To Computer Programming. February 29, 2012 Midterm

2nd GRADE-Math Year at a Glance

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

Exam 2 Review. 2. What the difference is between an equation and an expression?

As stated earlier, the declaration

Shapes leading to CAD system project

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

ADW GRADE 3 Math Standards, revised 2017 NUMBER SENSE (NS)

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

RD Grade Math Unit 1 Dates: Aug 3 rd - Sept 1 st. Alignment to Indiana Academic Standards: Topics A-F Alignment:

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Chapter 15 - C++ As A "Better C"

Relate volume to the operations of multiplication and addition and solve real world and mathematical problems involving volume. (5.MD.

By the end of this section you should: Understand what the variables are and why they are used. Use C++ built in data types to create program

ASSIGNMENT 2. COMP-202A, Fall 2011, All Sections. Due: Monday, October 17th, 2011 (23:30)

Week 3: Objects, Input and Processing

DIOCESE OF HARRISBURG MATHEMATICS CURRICULUM GRADE 8

Lab ACN : C++ Programming Exercises

A triangle that has three acute angles Example:

CURRICULUM UNIT MAP 1 ST QUARTER

ADW GRADE 5 Math Standards, revised 2017

Glossary Common Core Curriculum Maps Math/Grade 6 Grade 8

Topic 2: C++ Programming fundamentals

The C++ Language. Arizona State University 1

MCAS/DCCAS Mathematics Correlation Chart Grade 6

AP Computer Science Unit 1. Writing Programs Using BlueJ

Montana City School GRADE 5

2 nd Grade Math Learning Targets. Algebra:

PIC 10A. Review for Midterm I

Expressions and Casting. Data Manipulation. Simple Program 11/5/2013

Developed By Strawberry

Standard 1 Students will expand number sense to include integers and perform operations with whole numbers, simple fractions, and decimals.

2.1. Chapter 2: Parts of a C++ Program. Parts of a C++ Program. Introduction to C++ Parts of a C++ Program

1.1 - Functions, Domain, and Range

Adobe Flash CS3 Reference Flash CS3 Application Window

Summer Math Assignments for Students Entering Integrated Math

Chapter 1: Variables, Expressions, and Integers

EECS 211 Lab 8. Inheritance Winter Getting the code. Inheritance. General Idea. An Example

Fractions. 7th Grade Math. Review of 6th Grade. Slide 1 / 306 Slide 2 / 306. Slide 4 / 306. Slide 3 / 306. Slide 5 / 306.

Introduction to Programming EC-105. Lecture 2

I Internal Examination Sept Class: - BCA I Subject: - Principles of Programming Lang. (BCA 104) MM: 40 Set: A Time: 1 ½ Hrs.

Transcription:

Honors Computer Science C++ Mr. Clausen Program 6A, 6B, 6C, & 6G Special Note: Every program from Chapter 4 to the end of the year needs to have functions! Program 6A: Celsius To Fahrenheit Or Visa Versa Part 2 (10 additional points) 1. You are going to add some lines of code to your program to convert a temperature from Celsius to Fahrenheit or from Fahrenheit to Celsius. Save the program as LastNameFirstNameP6A.cpp in your S: directory. 2. Add a do while loop to your int main function that repeats the entire program until the user enters a lowercase q or uppercase Q. The reserved word do should appear after all of the variable declarations and initializations. The while statement will be near the end of the int main function and needs to have a compound Boolean expression to consider both cases of upper case Q, and lower case q. Be sure to save your program before you run it, as you might end up with an infinite loop if your logic is not correct. save your program in the W network mapping, and the Program 6A folder. PROBLEM 6B: Numbers, Their Squares, and Their Cubes 25 points Write a program that uses a for loop that will ask the user for an integer between 1 and a user specified limit (I will test your program using the number 25) and print a list of these numbers, their perfect squares and their prefect cubes. Save the program as LastNameFirstNameP6B.cpp in your S: directory. To see a model for this program look at the source code for the program pizza.cpp or pizza2.cpp in the network directory titled: HonorsCompSciCFiles. Look in the folder, Text Book Programs and Ch4. As you type all your programs this year, be sure not to type past the 80-column line in Borland C++ 5.02 for Windows. If you have any statements longer than 80 columns, press the return key to wrap the statement around to the next line. 1. Type comments at the beginning of the program to display your name and other information just like those used for program 2A. Make sure to change the program name and program description in these comments, so that the program number, name, and description say what is listed above.

2. Include <iostream.h> so we can use the cout and cin commands. Also include <conio.h> so you can use getch() to leave your output displayed on the screen until the user presses any key to continue. Include <iomanip.h> so we can use the setw command. To raise one integer to another integer power you will need to add: #include <math.h>. 3. There are no constants to declare. 4. Don t forget to include comments for your functions, right before each of your function declarations. 5. Declare the function Display_My_Info ( ) in the function declaration section of the program. This should be a void function that doesn t take any parameters and doesn t return any values. In addition, declare functions for Get_Data(),and Display_Output(). The Get_Data() function should be a void function using a reference parameter of type int for the number that the user enters as the upper limit for your loop. Display_Output() should be a void function using a constant reference parameter for upper limit, and display the table of numbers, squares, and cubes. 6. Use a comment line with equal signs to separate all of the above from the int main function. For example: = 7. Inside the int main() function, declare all of your variables and then call the functions. Don t forget that value-returning functions are called in assignment statements, while void functions can be called just by writing the function name including any of the actual parameters. Then tell the user to press any key to continue, have your getch() command, and your return 0 command. 8. After the int main() function, have another comment line of subtraction signs to separate the above from your function implementation lines below. For example: //-------------------------------------------------------------------------------------------- 9. Implement all of the functions, separating each one from the other ones using comment lines of subtraction signs. 10. When you implement the function: Display_Output(), create a "heading" for these numbers and have the numbers listed in three columns on the screen. To format the numbers nicely use the setw command to set a width for each of the columns. You also want to right justify these numbers. This will require that you add #include <iomanip.h> to your preprocessor directives and use the following commands: cout << setiosflags (ios::right) ; and cout<< setw(10); To raise one integer to another integer power you will need to add: #include

<math.h>; This can be used in an assignment statement or in a cout statement. 11. After the last function implementation of every program, end your program with two comment lines of equal signs. This signifies the end of your source code. For Example: save your program in the W network mapping, and the Program 6B folder. PROBLEM 6C: Arithmetic Series 25 points Write a program to add all the numbers from 1 to a user specified limit (I will test your program using the number 100) and display the sum. The output of the program should be the numbers 1 through the upper limit in the first column, and the running total of the numbers in the second column. Although this could be written with a for loop, I am requiring that you to use a count controlled while loop instead. Save the program as LastNameFirstNameP6C.cpp in your S: directory. To see a model for this program look at the source code for the program pizza.cpp or pizza2.cpp in the network directory titled: HonorsCompSciCFiles. Look in the folder, Text Book Programs and Ch4. As you type all your programs this year, be sure not to type past the 80-column line in Borland C++ 5.02 for Windows. If you have any statements longer than 80 columns, press the return key to wrap the statement around to the next line. 1. Type comments at the beginning of the program to display your name and other information just like those used for program 2A. Make sure to change the program name and program description in these comments, so that the program number, name, and description say what is listed above. 2. Include <iostream.h> so we can use the cout and cin commands. Also include <conio.h> so you can use getch() to leave your output displayed on the screen until the user presses any key to continue. Include <iomanip.h> so we can use the setw command. 3. There are no constants to declare. 4. Don t forget to include comments for your functions, right before each of your function declarations. 5. Declare the function Display_My_Info ( ) in the function declaration section of the program. This should be a void function that doesn t take any parameters and doesn t return any values. In addition, declare functions for

Get_Data(),and Display_Output(). The Get_Data() function should be a void function using a reference parameter of type int for the number that the user enters as the upper limit for your loop. Display_Output() should be a void function using a constant reference parameter for upper limit, and display the table of numbers and the running totals. 6. Use a comment line with equal signs to separate all of the above from the int main function. For example: = 7. Inside the int main() function, declare all of your variables and then call the functions. Don t forget that value-returning functions are called in assignment statements, while void functions can be called just by writing the function name including any of the actual parameters. Then tell the user to press any key to continue, have your getch() command, and your return 0 command. 8. After the int main() function, have another comment line of subtraction signs to separate the above from your function implementation lines below. For example: //-------------------------------------------------------------------------------------------- 9. Implement all of the functions, separating each one from the other ones using comment lines of subtraction signs. 10. When you implement the function: Display_Output(), create a "heading" for these numbers and have the numbers listed in two columns on the screen. To format the numbers nicely use the setw command to set a width for each of the columns. You also want to right justify these numbers. This will require that you add #include <iomanip.h> to your preprocessor directives and use the following commands: cout << setiosflags (ios::right) ; and cout<< setw(10); 11. After the last function implementation of every program, end your program with two comment lines of equal signs. This signifies the end of your source code. For Example: The output should look something like this: Number Sum 1 1 2 3 3 6 etc until the user entered upper limit.

save your program in the W network mapping, and the Program 6C folder. Program 6G program First Animation 25 points For this program, don't draw any pictures in the background of the graphics screen. Keep the background a solid color (it can be black or any other solid background color). Don t forget that you must use functions for this program, and that you cannot use any global variables. Remember to use comments for your function declarations and to have Pre and Post Conditions for each function also. Your job is to animate an object (more than just a circle or rectangle, etc.) that you have drawn across the graphics screen. Keep your "object" simple and small like a small boat, car, plane, etc. For animation, draw the picture in a foreground color, then draw the same picture in the background color to erase it. DO NOT USE cleardevice( ) to erase your animated shape! Your animation cannot be strictly horizontal or vertical movement, it needs to be a combination of both, or be a linear animation from point (x 1, y 1 ) to point (x 2, y 2 ). You can also add parabolic motion or other mathematical motions from using other formulas that you may know. Use any type of loop that is appropriate to your animation. Remember the formula to calculate the equation of a line between 2 points: y y y y = ( x x ) 2 1 1 1 x2 x1 Note: When you use initgraph and tell the compiler where Borland s bgi module is use: c:\\bc5\\bgi an absolute directory reference, instead of relative directory reference (what the book uses c:..\\bgi ) I will deduct points off of anyone who does not make this change. This will work much better in our networked environment, because it is an absolute reference to the location of the bgi. The notation c:.. Simply moves up a level in your current directory. Our programs are on the network, and the absolute reference works best (especially for me when I need to grade your programs: get the hint?). Please use this graphics mode: int graphdriver = VGA, graphmode= VGAHI; save your program in the W network mapping, and the Program 6G folder.