PRG/218 Introduction to C/C++

PRG/218 Entire Class    PRG/218 ENTIRE CLASS NEW

Or you may purchase tutorials by the Week below.

PRG/218 Coding: Hello, World
PRG/218 Entire Class
PRG/218 Entire Class
PRG/218 C/C++ Fundamentals

PRG/218 Week 1

Everything listed for Week 1 is included in purchase!! 

 

Individual: C/C++ Fundamentals
Instructions:
Answer the following four questions in a Microsoft® Word document:
1. Can a C++ program be compiled using a C compiler or vice versa? Why or why

    not?
2. What is special about the main function in both programs, C and C++?
3. What are the four main components of an IDE in both programs, C and C++?
4. What do libraries allow you to do in in C++, and how do you incorporate libraries

    into a C++ program?
Name the document PRG218_Week1_YourName.docx.
Submit your document using the Assignment Files tab.

 

Individual: Coding: Hello, World
Instructions:

Includes 4 programs: firstprog.cpp, semiprob.cpp, runprob.cpp, and logicprob.cpp.

This is a two-part assignment.

Part 1: Download and install Microsoft® Visual Studio® Community 2017, an integrated development environment (IDE) used to create C/C++ programs. Use the linked tutorial, Build Your First C++ App: Install, if you need help with installation.
Part 2: Code, test, and execute a simple C++ program using the linked tutorial, Build Your First C++ App: Introduction, to ensure your IDE is set up correctly.

 

Part 1:
Read the following sections of the article, "Build Your First C++ App: Install," on the Microsoft® Visual Studio® website, explaining how to download and install the correct version of Microsoft® Visual Studio® Community 2017.
Note: You must install the workload Desktop Development with C++ to be able to compile and run C++ programs for this course.
After you have installed the software, follow these instructions to complete your ID configuration:
1. Launch Microsoft® Visual Studio® Community 2017.
2. From the main menu bar, choose Tools > Options > Debugging> Symbols.
3. On the dialog that appears, turn on the checkbox next to Microsoft Symbol Servers.
4. Click OK.
Note: It may be helpful to read the article "Getting Started in Visual Studio" on the Microsoft® Developer Network website.
Part 2:
Read through the lab materials, and complete the following labs in the "Introduction to Programming and the Translation Process" document:
• Lab 1.1, "Opening, Compiling, and Running Your First Program"
• Lab 1.2, "Compiling a Program With a Syntax Error"
• Lab 1.3, "Running a Program With a Run Time Error"
• Lab 1.4, "Working With Logic Errors"
Note: Instead of opening existing files, you are required to type the C++ source code yourself for each C++ program as noted in the lab materials. Also, you will create a project each week for each C++ program you write.
Create a new project in Microsoft® Visual Studio® as follows:
1. Launch Microsoft® Visual Studio®.
2. From the main menu, choose File > New > Project.
3. On the left of the New File dialog that appears, choose Visual C++.
4. On the right of the New File dialog, choose Win32 Console Application.
5. Near the bottom of the dialog, in the Name field, type firstprog.

6. Note the value in the Location field. You may leave this as the default value or change it by clicking the Browse button. However, it is important that you remember the value for this field, because this value indicates the folder in which Visual Studio® will place your C++ source files. You need to know this folder because after you finish creating your source code files, you will need to navigate here using Windows® Explorer and zip the CPP files together in order to submit them.
7. Click the OK button.
8. On the dialog that appears, click the Finish button.
9. A .cpp (C++ source code) file will appear in the editing window. This file contains some standard C++ code. You will be editing (replacing) this code to create each C++ program.
Complete the labs in the "Introduction to Programming and the Translation Process" document as follows:
• Read the lab instructions, and type the C++ code indicated in the lab instructions. The first C++ file you will create will be called firstprog.cpp.
Hint: Be sure to leave the line#include "stdafx.h"in the program. Also, be sure to insert your name where indicated in the comments for each program.
• To run the program, choose Debug > Start Without Debugging from the main menu, and choose Yes on the dialog that appears asking if you would like to build the program.
• If your program contains no errors, a Windows console (small black window with the header C:\Windows\system32\cmd.exe and white text) will appear. For example, for firstprog.cpp, the following text will appear on your console: "Now is the time for all good men/To come to the aid of their party/Press any key to continue..." To dismiss the console, you select it and click any key, or click the x that appears in the upper right corner of the console.
• If your program contains errors, a description of the errors will appear at the bottom of the screen. Read the error descriptions, follow the suggestions for fixing them (if any), and repeat the steps above until your program runs without errors.
Hint: If you need help debugging your program, try the following:
• Read the Microsoft® article "Debugging in Visual Studio."
• Turn on line numbers to help you match error descriptions with specific lines of code. To do so, choose Tools > Options > Text Editor >
All Languages from the main menu, and turn on the check box next to Line Numbers on the dialog that appears, then click OK.
• For additional help, post a question describing your problem in this week's discussion board.
After you complete all four labs, you will have created four different C++ programs: firstprog.cpp, semiprob.cpp, runprob.cpp, and logicprob.cpp.
These program files will be located beneath the directory specified in the Location field.
Note: If you have forgotten the location, you can find it by clicking File> New > Project.
Zip the four CPP source files into a single ZIP file named PRG218_Week1_YourName.zip.
Submit your ZIP file using the Assignment Files tab.

 

 

Week 1 Discussion Question: Coding as a Member of a Team
Professional programmers typically work in teams on large programs that have fairly long lifespans. Additionally,
because the programmers who will be asked to add features to, or debug, a program a year or more later may not be
the original creators of the program, good original design, logical functional composition, and clear commenting are
essential skills for any professional programmer.
Research at least two best practices for working on a large coding team.
Discuss the benefits and challenges of each of the practices you chose.

 

PRG/218 Variables, Operators, Data Types, and Decisions
PRG/218 CODING EXPRESSIONS
PRG/218 Entire Class
PRG/218 Variables, Operators, Data Types, and Decisions

PRG/218 Week 2

 

Everything listed for Week 2 is included in purchase!! 

 

Individual: Variables, Operators, Data Types, and Decisions
Instructions:
Using the worksheet provided, provide answers to the questions and complete the tables. Save the document with the name

  1. What is the difference between a variable and a literal in C/C++? Give a C++ code example of both. 
  2. Fill out the following table:

 

Assignment Operator

Arithmetic Operators

Relational Operators

Logical Operators

What do these operators do?

 

 

 

 

Example 1

 

 

 

 

Example 2

N/A

 

 

 

 

     3.  Fill out the following table:

 

Data Types

Data type

 

 

 

 

 

Example value 1

 

 

 

 

 

Example value 2

 

 

 

 

 

 

    4.  Write the C++ code necessary to determine if the value of a variable named

         myVariable is equal to 6. If the value of myVariable is equal to 6, then subtract

         one from the variable yourVariable.


Submit your assignment using the Assignment Files tab.

 

Individual: Coding: Expressions
Instructions:
Includes: name.cpp, circlearea.cpp, rectanglearea.cpp, and
stringchar.cpp.

Read through the lab materials, and complete the following labs in the "Introduction to the C++ Programming Language Process" document:
• Lab 2.1, "Working with the cout Statement"
• Lab 2.2, "Working with Constants, Variables, and Arithmetic Operators"
• Lab 2.3, "Rectangle Area and Perimeter"
• Lab 2.4, "Working with Characters and Strings"
Note: Instead of opening existing files, you are required type the C++ source code yourself for each C++ program as noted in the lab materials. Also, you will create a project each week for each C++ program you write.
After you complete all four labs, you will have created four C++ programs: name.cpp, circlearea.cpp, rectanglearea.cpp, and stringchar.cpp.
Zip the four source files into a single ZIP file named PRG218_Week2_YourName.zip.
Submit your ZIP file using the Assignment Files tab.

 

 

Discussion Question: Common Bug: = vs. ==
Accidentally using the assignment operator "=" when you meant to use the comparison "is equal to" operator "==" is a common programming mistake.
Research whether or not the compiler can catch this mistake. Additionally, experiment with a statement similar to if (6 == myVariable) and see if it compiles correctly.
If you determine that the compiler will not catch this mistake, discuss a programming practice that can help reduce these errors.

 

Discussion Question: Strongly vs. Weakly Typed Languages
Programming languages that require variables to be specific, known data types are called strongly typed languages; programming languages that do not have this requirement are called weakly typed languages.
Research whether C and C++ are considered strongly or weakly typed languages, respectively.
Discuss the benefits of strongly typed vs. weakly typed languages. What are the drawbacks?

 

 

PRG/218 Decisions, Arrays, and Functions
prg/218 Coding: Loops
PRG/218 Entire Class
PRG/218 Decisions, Arrays, and Functions

PRG/218 Week 3

 

Everything listed for Week 3 is included in purchase!! 

 

Individual: Decisions, Arrays, and Functions
Instructions:
Resource:
Week 3 Worksheet: Decisions, Arrays, and Functions
Carefully examine C++ source code and identify decision structures, array declarations, and the parts of a function.
Using the worksheet provided, provide answers to the questions.

Study the C++ code that appears on the next page and answer the following questions.

  1. On what line number(s) are if statements located? 
  2. On what line number(s) are case statements located? 
  3. On what line number(s) are loops located?  
  4. On what line number(s) are arrays declared?
  5. On what line number(s) are arrays accessed?
  6. On what line number(s) are function(s) declared?
  7. For every function you identified in #4 above:
    • Is the function ever called? 
    • What are the function’s arguments?
    • What value, if any, does the function return?

Submit your assignment using the Assignment Files tab.

 

Individual: Coding: Loops
Instructions:
Resource:
• Loops and Files of Starting Out with C++ from Control Structures Through Objects
Read through the lab materials, and complete the following labs in the "Loops and Files" document:
• Lab 5.1, "Working with the while Loop:
• Lab 5.2, "Working with the do-while Loop"
• Lab 5.3, "Working with the for Loop"
• Lab 5.4, "Nested Loops" (Exercise 1 only)
Note: Instead of opening existing files, you are required type the C++ source code yourself for each C++ program as noted in the lab materials. Also, you will create a project each week for each C++ program you write.
After you complete all four labs, you will have created five C++ programs: while.cpp, sentinel.cpp, dowhile.cpp, for.cpp, and nested.cpp.
Zip the five source files into a single ZIP file named PRG218_Week3_YourName.zip.
Submit your ZIP file using the Assignment Files tab.

 

 

Discussion Question: Choosing the Best Control Structure
C++ supports multiple control structures, as do most programming languages.
Discuss why you think this is. Give code examples, if necessary, to explain your reasons

 

Discussion Question: Benefits and Drawbacks of Arrays
Using arrays, programmers can create collections of items.
Research and post two real-life examples of grouped data that might be useful to model as an array. 
Describe how you could model those data collections as separate data items. What would be the benefits/drawbacks of modeling the data as an array vs. separate data items?

 

 

 

prg/218 OO Basics
prg/218 Coding: Classes and Objects
PRG/218 Entire Class
PRG/218 OO Basics

PRG/218 Week 4

 

Everything listed for Week 4 is included in purchase!! 

 

Individual: OO Basics
Instructions:
Carefully examine the code in Program 13-15, "Implementing the Class," in Section 13.13, "Focus on Problem Solving and Program Design: An OOP Case Study," in Ch. 13, "Introduction to Classes," of Starting Out With C++ From Control Structures Through Objects. Answer the following four questions in a Microsoft® Word document:
1. On what line number(s) is the Account class instantiated?
2. Is the Account class declared in the code in Program 13-15? If not, where is the

    Account class declared and how do you know this?
3. On what line number(s) is the Account class constructor called?
4. On what line numbers are Account member functions called?
Name the document PRG218_Week4_Worksheet_YourName.docx.
Submit your assignment using the Assignment Files tab.

 

Individual: Coding: Classes and Objects
Instructions:
Review the video "Challenge: Ask For a User's Favorite Movies" in Lesson 4, "Classes and Objects," of the Lynda.com® course Learning
C++ with Peggy Fisher. Take notes on the program requirements.
Create a MyMovie class along with a main program that prompts a user with questions about his or her favorite movies, places the user's answers in an array, and then applies content from the array to the creation of MyMovie objects. Create a single C++ project (favoriteMovies) containing three interrelated files (favoriteMovies.cpp, Movie.cpp, and Movie.h) as follows:
• Create a new project In Visual Studio® named favoriteMovies.
• Type in the code for favoriteMovies.cpp. You may begin with the
example favoriteMovies.cpp file located in Lynda.com® example, if you like.
• From the Visual Studio® main menu, choose Project > Add Class, then choose Visual C++ and click the Add button.
• In the "Generic C++ Class Wizard" dialog, type MyMovie as the class name. Then, for the .h file and .cpp file fields, type Movie.h and Movie.cpp, respectively. Click the Finish button.
• Type the Movie.h and Movie.cpp code into each of these files.
• From the main menu, choose Debug > Start Without Debugging, and build/debug/run as usual.
After you have created your version of the program, view the solution provided in the video "Solution: Ask For a User's Favorite Movies" in Lesson 4, "Classes and Objects," of the Lynda.com® course Learning C++ with Peggy Fisher. Sample source code is also available in the Exercise Files linked in Lynda.com® course.
Note: To earn full credit for this assignment, the source code you submit must differ from the sample source code in the following ways:
• It must be structured differently, with different variable names and control flow
• Or, if it is structured in a similar fashion, the following changes must be included:
• The program must accept movies that were released between 1950 and 2017
• The Movie class must be named MyMovie

• The comments header of each file must include your name as the
author and "Week 4" as the date
Zip the three source files into a single ZIP file named PRG218_Week4_YourName.zip.
Submit your ZIP file using the Assignment Files tab.

 

Discussion Question: Functions vs. Member Functions
You can think of normal functions as "black boxes" that accept parameters (or not), do some processing, and return some value (or not). 
Member functions (sometimes referred to as "methods" in other object-oriented programming languages, such as Java) are similar in some ways to normal functions, but also dissimilar. 
Research and discuss the ways in which a C++ member function is like and unlike a regular function.

 

Discussion Question: Void Functions
Describe what a void function is, and explain how it differs from other functions. In what situations would a programmer use a void function? 
List at least one specific example of when a void function would be appropriate and one specific example of when a non-void function would be appropriate.

 

Inheritance and Data Protection
PRG/218 Coding: Derived Classes
PRG/218 Inheritance and Data Protection
PRG/218 Inheritance and Data Protection

PRG/218 Week 5

 

Everything listed for Week 5 is included in purchase!! 

 

Individual: Inheritance and Data Protection
Instructions:
One of the capabilities that makes object-oriented programming so powerful is inheritance because it allows programmers to model realworld relationships.
Answer the following two questions in a Microsoft® Word document:
1. What are the benefits of inheriting one or more derived classes from a base class?

    What are the drawbacks?
2. The base class PatientRecord contains a variable X declared as private, a

    variable Y declared as protected, and a variable Z declared as public. The classes

    InsuredPatientRecord and UninsuredPatientRecord both derive from

    PatientRecord. Which of the base class's variables, if any, can the derived classes

    access? Why?
Name the document PRG215_Week5_Worksheet_YourName.docx.
Submit your assignment using the Assignment Files tab.

 

Individual: Coding: Derived Classes
Instructions:
Create a base class and two derived classes. Also, create and call a member function named communicate() that behaves differently when called by each class. Create a single C++ project (and CPP source file) named animal_communication as follows:
• Into this source, type the source code for Program 15-16, "Program Output," in Section 15.6, "Polymorphism and Virtual Member Functions," in Ch. 15, "Inheritance, Polymorphism, and Virtual Functions," of Starting Out With C++ From Control Structures Through Objects.
• Run and debug the code as necessary.
• Create a new class named Cat that derives from the base class Animal.
• In the main portion of the program, add code to instantiate the Cat class and telegraph that the Cat class's constructor and destructor are being called.
Note: To do this, you may copy and customize the code that does this for the Dog class, choosing a variable name such as myAnimal2 for the instantiation of the Cat object.
• Create a member function called communicate() in the base Animal class, the Cat class, and the Dog class. The communicate() member function should produce "Speak" when called on an instance of Animal, "Woof!" when called on an instance of Dog, and "Meow!" when called on an instance of Cat as follows:


// Class member function for Animal
// Place public function below the constructor
// and destructor in the Animal class.
void communicate() {
cout << "Speak." << endl;
}
// Class member function for Dog
// Place public function below the constructor
// and destructor in the Dog class.
void communicate() {
cout << "Woof!" << endl;
}
// Class member function for Cat
// Place public function below the constructor
// and destructor in the Cat class.
void communicate() {
cout << "Meow!" << endl;
}
• In the main portion of your program, instantiate the Animal, Cat, and Dog classes as shown below, and then call the communicate member function on each instance as follows:


int main() {
Animal genericAnimal;
genericAnimal.communicate();
Dog ralph;
ralph.communicate();
Cat fluffy;
fluffy.communicate();
return 0;
}
Save your C++ code in a file named Week5Program_YourName.cpp, and take a screenshot of your running program. Copy your screenshot in to Microsoft® Word document.
Zip both your screenshot document and CPP source into a single ZIP file named PRG218_Week5_YourName.zip.
Submit your ZIP file using the Assignment Files tab.

 

 

Discussion Question: Why Declare Private Data?
Technically, it is possible for C++ programmers to declare class data as public, meaning any statement in the program could access and change the data directly. 
Discuss some reasons most programmers declare class data to be private and provide access to that data only through the use of accessor and mutator (or "getter" and "setter") member functions.
Hint: What benefits do programmers get from doing this extra work?

 

 

Discussion Question: Object-Oriented Design Methodologies
The concept of inheritance is used in many situations, not just in object-oriented programming (OOP). The Linnaeus classification system is one well-known example. If modeling the taxonomy in code, we might start with an animal class, then derive two other classes (vertebrates and invertebrates) from the base animal class, then derive other classes (such as mammal and reptile) from the vertebrate class, and so on. In short, the purpose of inheritance, and object-oriented design, as well as programming in general, is to allow programmers to model the real world. In other words, the goal is to design object-oriented programs that are understandable by people familiar with the real-world system and behave in a predictable fashion.
Research at least three object-oriented design methodologies or approaches, including UML (Unified Modeling Language), OMT (Object Modeling Technique), and OOSE (Object-oriented Software Engineering)..
Discuss how the various methodologies differ. How are they alike?