Make sure to put the correct comment character(s) before ...



CSE 1321L - C++Introduction to C++ and Visual StudiosLab 1Goals: Become familiar with the Visual Studios Integrated Development Environment (IDE).Explore how C++ applications work and understand the main method.For each lab program you develop, make sure to include the following header - replace the dots with your section #, semester, your full name, your instructor’s name, and lab #:Class:CSE 1321LSection: ... Term:... Instructor:... Name:... Lab#:...Make sure to put the correct comment character(s) before the above lines in each file. C++, C#, and Java use // for one line comments. Use /* */ for block comments (put comments between the characters).What is an IDE?An Integrated Development Environment, or IDE, is basically an app that programmers use to make their lives easier writing and testing code. You can think of it as Word (or Pages if you use a Mac) but instead of using English or some other Human language, it works with one or more languages that computers can understand. More formally, its an application that provides almost everything needed by?computer programmers?for?software development. An IDE normally consists of at least a?source code editor,?build automation?tools (like compilers), and a?debugger. You can see a larger overview on Wikipedia: do we use an IDE?It simplifies the whole process, allowing programmers to write and test code quicker and with less errors. On top of that, many modern IDEs also help multiple developers coordinate their work and provide fast and intelligent error catching systems. So all of this together makes any IDE a one stop place to write, compile, run, and fix code.Directions:Open Visual Studios on your computer.Click File ? New ? Project and a pop-up window will open.Select Visual C++ from the left side of the window.Select Win32 Console Application from the middle of the window.Make sure to change the name at the bottom. For example, “1321L_Lab1".Click ok and you will see another pop-up window.Click next and then ONLY uncheck the two boxes (Precompiled header and SDL checks).Click finish and the project will open. At the top of the code, add the following two lines:#include <iostream>#include <string>Below that and inside of the curly brackets, type the following text as is:printf("This is my first C++ program! \n");printf("This program does not do much! \n\n”);Click File Save (CTRL + S) to save the updated file to the hard drive.Now, let’s indent the code properly. Press CTRL + K then CTRL + D to format the whole file. Click the Save icon.Now we need to compile/build the code. Click on the Build tab in the toolbar and select the first option, Build Solution. Notice what the compiler displays in the lower window (Build tab). If you have syntax errors, error messages are displayed in that window. Notice that a red underline will occur under the code with the error.Remember you must rebuild the code every time you change it before being able to run it.Once you fix all syntax errors, you are ready to execute the program to see its results. Go to the Debug tab in the toolbar and select the 5th option, Start without Debugging. You should see a pop-up window with the output. Notice what the run-time machine displays in the lower window (Debug tab). Notice that Visual Studios saves your file each time you try to build the code and will ask you to build the code before running it, if you forget to build after changing the code.Copy and paste the code below into the same file. Make sure to place it below the “#include” statements but above the “int main()” method.Inside the same curly brackets as step 10 (inside your “int main()” method), write the names of each method below followed by a set of parenthesis and a semi-colon. For example: CoutDown();Then build your solution and run it again to see their output and get full credit for this lab.================================== Method CountDown ==================================// Method CountDown// Demonstrate the difference between printf using \n and without it. // Prints two lines of output representing a rocket countdown. void CountDown(){printf("Three... ");printf("Two... ");printf("One... ");printf("Zero... ");printf("Liftoff!\n"); // appears on first line printf("Houston, we have a problem. \n\n");}================================== Method Addition ===================================// Method Addition// Demonstrate the difference between the addition and stream concatenation operators. // Concatenates and adds two numbers and prints the results. void Addition(){std::cout << "24 and 45 concatenated: " << 24 << 45 << std::endl;std::cout << "24 and 45 added: " << (24 + 45) << std::endl << std::endl;}==================================== Method Echo =====================================// Method Echo// Demonstrate reading a string from the user. // Reads a character string from the user and prints it. void Echo(){std::string message;printf("Enter a line of text:");getline(std::cin, message);std::cout << "You entered: " << message << std::endl;}=================================== Method GasMileage ================================// Method GasMileage// Demonstrate the use of the cin, or standard input stream to read numeric data.// Calculates fuel efficiency based on values entered by the user.void GasMileage(){int miles;double gallons, mpg;printf("Enter the number of miles: ");std::cin >> miles;printf("Enter the gallons of fuel used: ");std::cin >> gallons;mpg = miles / gallons;std::cout << "Miles Per Gallon: " << mpg << "\n" << "\n";}==================================== Method Facts ====================================// Method Facts// Demonstrate output stream concatenation of an integer and a string. // Prints various facts.void Facts(){// Strings can be concatenated into one long string std::cout << "We present the following facts for your " << "extracurricular edification:" << std::endl;std::cout << std::endl;// A string can contain numeric digits std::cout << "Letters in the Hawaiian alphabet: 12" << std::endl;// A numeric value can be concatenated to a string std::cout << "Dialing code for Antarctica: " << 672 << std::endl;std::cout << "Year in which Leonardo da Vinci invented " << "the parachute: " << 1515 << std::endl;std::cout << "Speed of ketchup: " << 40 << " km per year" << std::endl;}Instructions:1. All practice programs must be completed and working correctly.2. The programs must be checked by the end of the designated lab session by Lab Instructor or TA.3. Source code files (.cpp and .h) must be uploaded to D2L by due date. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download