Instructions

  • Due {lab00-due}

  • Use the repl.it C++ template to complete the following.

  • Write up your results in the editor of your choice (e.g., Office, Google Docs, etc.)

  • Export your document as a pdf (try "Print to PDF")

  • Upload your pdf:

    • {lab00-submit}

Part 1 (30 Points)

The purpose of Part 1 is to produce a catalog of typical syntax errors and the resulting error messages, and to gain familiarity with a programming environment. This exercise should familiarize you with common mistakes to look out for, and their solutions.

  • Compile and run the code chunk below.

  • You will deliberately introduce errors to the working program and compile

    • Record the error and associated error message.

    • Fix the error and confirm a working program before moving on to the next error

  • List of errors to introduce:

    1. Put an extra space between the < and the iostream file name.

    2. Omit one of the < or > symbols in the include directive.

    3. Omit the int from int main() .

    4. Omit or misspell the word main .

    5. Omit one of the ( ), then omit both the ( ).

    6. Omit one or both of the << in the cout statement;

    7. Omit the ending curly brace }.

#include <iostream>
using namespace std;
int main( )
{
    int nbitcoin;
    double value_per_coin, total_value;

    cout << "Enter the number of bitcoin in wallet.\n";
    cin >> nbitcoin;
    cout << "You entered: " << nbitcoin << endl;

    cout << "Enter the dollar value of one bitcoin.\n";
    cin >> value_per_coin;
    cout << "You entered: " << value_per_coin << endl;

    total_value = value_per_coin * nbitcoin;
    cout << "Total value in wallet is " << total_value << " dollars." << endl;
    return 0;
}

Part 2 (30 Points)

Write a C++ program that reads in two integers and then outputs both their sum and their product (you may modify the above sample).

In your writeup, include the code and three different runs (with different inputs) of the program.

Part 3 (40 Points)

Write a program that allows the user to enter a number of quarters, dimes, and nickels and then outputs the monetary value of the coins in cents. For example, if the user enters 2 for the number of quarters, 3 for the number of dimes, and 1 for the number of nickels, then the program should output that the coins are worth 85 cents.

In your writeup, include your code and three different runs of the program.