How to enter and save a program- compile and run a program

Assignment Help Basic Computer Science
Reference no: EM13923326

Student Lab Activity
A. Lab # CIS CIS170C-A1
B. Lab 1 of 7: Getting Started (Your First C++ Programs)
C. Lab Overview - Scenario/Summary

Welcome to Programming with C++. The purpose of this three-part lab is to walk you through the following tutorial to become familiar with the actions of compiling and executing a C++ program.

In general, this lab will instruct you on:

  • how to create a project;
  • how to enter and save a program;
  • how to compile and run a program;
  • how to, given a simple problem using input and output, code and test a program that meets the specifications; and
  • how to debug a simple program of any syntax and logic errors.

D. Deliverables

Step 6: Program Listing and Output

Program Listing and Output
Program Listing and Output

E. Lab Steps

Preparation:

If you are using the Citrix remote lab, follow the login instructions located in the iLab tab in Course Home.

Lab:

Part A: Getting Started
Step 1: Start the Application
From the File menu, choose "New Project."
Choose "Win32 Console Application."
Enter a name in the name field.
Click "OK"
Click "Next" and choose the following options:
Application Type: "Console Application"
Additional options: Check mark "Empty project".
Click Finish. Your project is now created.

Step 2: How to Add a Source Code File to Your Project (.cpp file)

In the Solution Explorer, right-click on the "Source Files" folder and select "Add" and then "New Item."
In the next dialog box, choose C++ file (.cpp), enter a name for your source code file, and press the Add button.
Type or copy and paste your code into the newly created source code file. Build the file by pressing F7, and then execute your program by pressing CTRL-F5 (start without debugging) or use the F5 key (Start Debugging).


Step 3: Create a Source Code File
Now enter the following C++ program exactly as you see it. Use the tab where appropriate. [Note: C++ is case sensitive.] Instead of John Doe, type your name.

#include <iostream>

using namespace std;

void main()
{
cout << "John Doe" << endl;
cout << "CIS170C - Programming using C++\n";
cout << "\n\n\nHello, world!\n\n";

}

When you execute a program in debug mode (F5), the console screen may appear and disappear before you have an opportunity to view your output. There are several techniques you can use to pause the console screen so you can read the output. On the very last line in the main() function:
a. insert the statement: system("pause");
-OR-
b. insert an input statement: cin >> myVarable;

Step 4: Output
The black screen or console should read:
John Doe
CIS170C - Programming using C++
Hello, World -
Step 5: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, or by clicking the Save button on the toolbar, or Ctrl + S.

Step 6: Build Solution
To compile the program, click Build on the menu bar and then click the Build Solution or Build LabA option. You should receive no error messages. If you see some error messages, check the code above to make sure you didn't key in something wrong. Once you make your corrections to the code, go ahead and click Build >> Build Solution again.

Step 7: Execute the Program
Once you have no syntax errors, to execute or run your program, click Debug on the menu bar, and then click Start Without Debugging.

Step 8: Capture the Output
Print a picture of your screen output. (Do a print screen and paste this into MS Word.)

Step 9: Print the Source Code
Copy your source code and paste it into the same Word document as your screen print. Save the Word Document as Lab01A_LastName_FirstInitial

Note: Using the Visual Studio editor to compile your programs creates a lot of overhead. These additional files will become important as you create more sophisticated C# projects. Projects can contain one or more source-code files. For this course, you will not have to worry about all the extra files that are created.

End of Part A

Part B: Calculate Total Tickets

Step 1: Create New Project
Now create a new project and name it LAB1B. Make sure you close your previous program by clicking File >> Close Solution.

Step 2: Type in Program
Like before, enter the following program. Type in your name for Developer and current date for Date Written.

// ---------------------------------------------------------------
// Programming Assignment: LAB1B
// Developer: ______________________
// Date Written: ______________________
// Purpose: Ticket Calculation Program
// ---------------------------------------------------------------

#include <iostream>

using namespace std;

void main()
{
int childTkts, adultTkts, totalTkts;

childTkts = 3;
adultTkts = 2;
totalTkts = childTkts + adultTkts;

cout << totalTkts << endl;
}

Step 3: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, or by clicking the Save button on the toolbar, or Ctrl + S.

Step 4: Build Solution
To compile the program, click Build on the menu bar and then click the Build Solution or Build LabB option. You should receive no error messages. If you see some error messages, check the code above to make sure you didn't key in something wrong. Once you make your corrections to the code, go ahead and click Build >> Build Solution again.

Step 5: Execute the Program
Once you have no syntax errors, to execute or run your program, click Debug on the menu bar, and then click Start Without Debugging.

Step 6: Capture the Output
1. Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.)
2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.
3. Save the Word Document as Lab01B_LastName_FirstInitial.
End of Part B

Part C: Payroll Program
Step 1: Create a New Project
Create a new project and name it LAB1C. Make sure you close your previous program by clicking File >> Close Solution.

Include a comment box like what you coded in Part B. This can go at the very top of your program.

Step 2: Processing Logic
You need to write a program that calculates and displays the take-home pay for a commissioned sales employee along with all of the deductions.

Input: Prompt the user for the weekly sales.
Process: Perform the calculations. The employee receives 7% of his or her total sales as his or her gross pay. His or her federal tax rate is 18%. He or she contributes 10% to his or her retirement program and 6% to Social Security.
Output: Display the results
Sample Output from Lab 1:
Enter Weekly Sales: 28000
Total Sales: 28000.00
Gross pay (7%): 1960.00
Federal tax paid: 352.80
Social security paid: 117.60
Retirement contribution: 196.00

Total deductions: 666.4

Take home pay: 1293.60
Press any key to continue . . .
Flowchart: (continued on next page)

Pseudo Code:

1. Declare variables
2. Accept Input - weeklySales
3. Calculate Gross Pay = Weekly Sales * .07
4. Calculate Federal Tax = Gross Pay * .18
5. Calculate Social Security = Gross Pay * .06
6. Calculate Retirement = Gross Pay * .1
7. Calculate Total Deductions = Federal Tax + Social Security + Retirement
8. Calculate Total Take Home Pay = Gross Pay - Total Deductions
9. Display the following on separate lines and format variables with $ and decimal.
a. Total Sales Amount: value of weekly sales
b. Gross Pay (.07): value of gross pay
c. Federal Tax paid (.18): value of federal tax
d. Social Security paid (.06): value of social security
e. Retirement contribution (.1): value of retirement
f. Total Deductions: value of total deductions
g. Take Home Pay: value of take home pay

Note: Use SetPrecisions(2) to format the output (see page 98 of the text). The statements should look something like the following:

//include the iomanip header file at the top of the file
#include <iomanip>

//use fixed and setprecision(2) to format the number
//use setw(8) to control the width of the field
//use \t to control the spacing between fields
cout << fixed << setprecision(2);
cout << "Gross Pay (0.07):\t tiny_mce_markerquot; << setw(8) << grossPay << endl;

Step 3: Save Program
Save your program by clicking File on the menu bar and then clicking Save Program.cpp, or by clicking the Save button on the toolbar, or Ctrl + S.

Step 4: Build Solution
To compile the program, click Build on the menu bar and then click the Build Solution or Build LabC option. You should receive no error messages. If you see some error messages, check the code above to make sure you didn't key in something wrong. Once you make your corrections to the code, go ahead and click Build >> Build Solution again.

Step 5: Execute the Program
Once you have no syntax errors, to execute or run your program, click Debug on the menu bar, and then click Start Without Debugging.

Step 6: Capture the Output
1. Capture a screen print of your output. (Do a PRINT SCREEN and paste into an MS Word document.)
2. Copy your code and paste it into the same MS Word document that contains the screen print of your output.
3. Save the Word Document as CIS170A_Lab01_C_LastName_FirstInitial.

Reference no: EM13923326

Questions Cloud

Type of sampling technique was used to collect the data : Enter the Data set (see next page: 50 samples of employee of two offices in Dubai & Abu Dhabi) into MINITAB stat software, run the required analysis, and answer the listed questions:
Directions for the skills based assessment : The final exam for this course is a comprehensive lab activity. You may consult with other students on this lab if you wish, but each student should submit a separate lab that represents your own work.
Completing the project follows a normal distribution : The mean time to complete a construction project is 52 weeks with a standard deviation of 3 weeks. Assuming the probability of completing the project follows a normal distribution, what is the probability of completing the project between 56 week..
Compute the sharpe measure for the market portfolio : Compute the Sharpe measure for each portfolio and the market portfolio. Compute the Treynor measure for each portfolio and the market portfolio
How to enter and save a program- compile and run a program : Welcome to Programming with C++. The purpose of this three-part lab is to walk you through the following tutorial to become familiar with the actions of compiling and executing a C++ program.
Determine auditing a firm''s ending inventory balance : You are building your audit plan and trying to determine your approach to auditing their ending inventory balance as well as the long-term debt balance.
Calculate both the treynor measure and the sharpe measure : Calculate both the Treynor measure and the Sharpe measure for both Portfolio X and the S&P 500. Briefly explain whether Portfolio X underperformed, equaled, or outperformed the S&P 500.
How many drinks would the average person have : How many drinks would the average person have to consume to reach a blood alcohol level of approximately 0.15%
Prevent the successful application : Select one of the major trade theories and answer the following question: What cultural, physical, economical, financial, and political impediments might prevent the successful application of your selected trade theory?

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What is physical security

What is physical security? What are the primary threats to physical security? How are they manifested in attacks against the organization? What are certification and accreditation when applied to information systems security management? List and..

  Create a local area network

Create a local area network (LAN) design diagram of the current network that describes the hardware and software resources that Matt described.

  Effective user-level thread implementation

What must a kernel provide for an effective user-level thread implementation? Do you have immediate help for this answer?

  Develop a multi-agent based recommender system architecture

Develop a multi-agent based recommender system architecture for multi-site software development to support collaborative behavior around the software engineering ontology.

  How do we provide documentation to the user

How do we provide documentation to the user? How do we use JavaDoc to generate user documentation in a standard form? How do we bundle all of our application class files and deliver something to the user that is executable?

  How many different colors could be represented with an rgb

How many different colors could be represented with an RGB scheme if only 3 bits were used to represent each RGB component (3 for R, 3 for G, 3 for B)?

  The convergence of different devices such as cameras

Think about how mobile our computing devices have become and the convergence of different devices such as cameras, phones, and computers. What do you think the computer of the future will be like? What capabilities will it have that computers ..

  Runtime is an important concept in matrix operations

Runtime is an important concept in matrix operations in computer applications, particularly when massive calculations are involved in programming. In this week's discussion, you will explore these applications. Step I:Define the termruntime,and list..

  Explain how is a dsl interconnection distinct from the

q1.what are the basic principles that apply to all networks?q2.what is an ethernet card?q3.what does a network switch

  Write single statement print message first is followed first

Write a single statement that will print the message "first is " followed by the value of first, and then a space, followed by "second = ", followed by the value of second.

  Sequence of assembler directives

Write a sequence of assembler directives to build a table of ASCII codes of lower case letters a-z. The table should start from memory location $2000. Note: use assembler directives only.

  Simple math quiz that asks a user

Construct a simple math quiz that asks a user to answer a math problem of your choice. On the form, place one text box (txtAnswer) and two command buttons (cmdAskQuestion and cmdVerifyAnswer).

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd