CSCE 2004 - Laboratory Assignment 1

    The objective of this laboratory assignment is to introduce students to the NetBeans IDE and C++ compiler that we will be using this semester. CSCE students must have a valid University of Arkansas account to perform this lab. Use the UARK username and your UARK password that you use to access your UARK email to login to the system.

  1. Register for CSCE 2004

    Use the Internet browser to open the website CSCE-Moodle . Use your UARK username and password credentials to login. Then, use the following steps to register for the CSCE2004 course.

    1. In the navigation menu to the left, click on "My Home".
    2. In the same menu, click on Courses > CSCE. You will find the courses that are offered by the CSCE department
    3. Click on CSCE 2004 (SP 2012). A new window should appear prompting that you should enter "Enrolment Key" of the course. Ask your TA about the Key to complete registering in the course.

  2. Introduction to the NetBeans IDE

    NetBeans is an Integrated Development Environment (IDE) for developing with a number of programming languages such as Java, Java Script, PHP, C, C++, etc. The NetBeans IDE is written in Java and can run anywhere a compatible JVM is installed, including Windows, Mac OS, Linux, and Solaris. For this course, we will use Mac OS, see Mac Home. Also, you can visit Creating C++ application in NetBeans for information about creating C++ applications in NetBeans.

  3. Creating a C/C++ Application Project

  4. A. Create a C++ Project
    1. Open the New Project wizard by choosing File > New Project.
    2. In the wizard, select the C/C++ category.
    3. The wizard gives you a choice of several types of new projects. Select C/C++ Application and click Next.
    4. Create a new C/C++ Application project from the wizard using the defaults. You can choose the name of the project and the location of the project. Name your project as Lab1
    5. Click Finish to exit the wizard.

    Open the source files folder in your application (in the left menu), you will find a main.cpp file. Write the following code in the main.cpp file.

       
    // By: Your name
    // ID: Your Course ID
    // Date: Today's Date
    
    #include <iostream>
    using namespace std;
    
    int main()
    {
       return 0;
    }
    

    B. Building Your Project

    To build your project:

    Choose Run > Build Main Project and the projects builds. The build output is shown in the Output window.

    You can build, clean, or both clean and build the project by choosing actions from the Run menu.

    C. Compiling a Single File

    To compile a single source file:

    Right-click on the main.c file and choose Compile File. Only this file is compiled.

    D. Running the program

    In the main menu, choose Run > Run Main Project. An output window will show up, but there is no output in it since your program does not have any output statements. Press Enter to exist the window.

    E. Extend your program

    Add the following two lines to your program.

        cout << "By: your name" << "\n";
        cout << "Hello, World!\n";
    

    After editing the program, compile and run the program, and check the output in the output window

    F. Debugging

    Make a syntax error in your program (i.e remove the semicolon after the second statement), and check what happens. You can see a red sign on the left on the number of the corresponding line. Move the mouse over the sign and see the message. Before fixing the error, go to the main menu, click Run > Build Main Project. Then, see what is written in the output window (at the bottom). Fix the error, build and run the program again.

    G. Writing a program

    Copy and Paste the following code into your main file

       
    
    // By: 
    // ID: 
    // Date: 
    
    #include <iostream>
    using namespace std;
    
    int main()
    {
       //Define Variables
        double CoatPrice = 83.7;
        double PantPrice = 23.5;
        double CapPrice = 10.8;
        const double TAX = 0.16;
        double SumBeforeTax;
        double SumAfterTax;     
        double TotalTaxAmount;   //total amount of tax on the sale
        double AveragePrice;    // the average price of the items 
        
        // calculate the cost before Tax
        Sum = CoatPrice + PantPrice + CapPrice;
        cout << " The Cost before Tax is: "<< Sum << endl;
           
        
        //1. Calculate the Total Taxes amount and print it out on the screen  
    
    
        //2. Calculate the cost after taxes  and print it out on the screen
    
        
        //3. Calculate the average cost of purchased items after taxes and print it out on the screen
    
    
    return 0;
    }
    
    1. Fix the error in the code.
    2. Fill in the missing Code.
    3. Build and Run your project.
    4. Add the output to your code as comments at the end of your program.
    5. Upload your file in the previous step using Moodle, as explained in the next section.

  5. Submit Work

    You can submit the lab assigment using Moodle as follows.

    1. Using the navigation menu (in the left), click on My Courses > CSCE 2004.
    2. Click on the related week, which is 23 January - 29 January, then choose the appropriate lab assignment
    3. Use the Upload Files bottom to upload your code. Make sure to upload your code in .cpp format.
    4. Use the bottom "Send for marking" to confirm uploading.