/* 3_16 calculating interest earned Write a program that asks for principal, interest rate, # of times compounded, and calculate interest earned. */ #include<iostream> #include<cmath> // Needed for pow function #include<iomanip> // Need for manipulating text using namespace std; int main() { float amount, principal, rate, interest, calc_rate; // Declare variables double time; // Ask for inputs. cout << "This program calculates interest earned.\n"; cout << "What is the principal (beginning balance)? \n"; cin >> principal; cout << "What is the interest rate in percent? \n"; cin >> rate; cout << "How many times a year will the principal be compounded? \n"; cin >> time; // Limit deciamals to 4. cout << setprecision(4) << fixed; // Convert rate to decimal for calculations. rate *= 1 / 100.0; // Make interest rate constant throughout program. const float RATE = rate; // Calculate parenthesis first calc_rate = 1 + (RATE / time); // Inside calc_rate = double pow(calc_rate, time); // Inside raised to Time // Calculate amount amount = principal * calc_rate; // Calculate interest interest = amount - principal; // Output the results. cout << "Here are the results:\n"; cout << endl; cout << setprecision(0) << fixed; // Interest rate. cout << left << "Interest rate:" << setw(30) << right << RATE << endl; // Time. cout << left << "Number of times compounded in a year:" << setw(30) << right << time << endl; // Output following to 2 decimals. cout << setprecision(2) << fixed; // Output principal cout << left << "Principal:" << setw(30) << right << principal << endl; // Interest. cout << left << "Interest earned:" << setw(30) << right << interest << endl; // Amount in savings. cout << left << "Amount in savings:" << setw(30) << right << amount << endl; return 0; }

error says: expected primary expression before double

and : expected ; before double.

what am I doing wrong?

Thanx