Activity: Output Precision (iPad)

The Assignment

Working with your partner, write a program which outputs the variable account_balance with two digits of precision, a dollar sign, and an appropriate message. For example, if the input is 200.9876, the output should be :

Your Account Balance is $200.99.

Begin by creating a new C++ file called OutputPrecision.cpp in the iPad C++ compiler. Next, copy and paste this starter code into the file:

#include <iostream>
#include <cmath>

using namespace std;

int main() 
{
   // declare a variable to store the account balance...
   double account_balance = 0.0;

   // input the value from the user...
   cin >> account_balance;

   /* Add your code here... */

   return 0;
}

Modify the code to complete the assignment. When you have completed the assignment, demonstrate it for the instructor.