expected `;' before "pennies"? C++ Debugging (Code Completed)
- by Josh Lake
Can anyone tell me why I get an error on my last cout?
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <cstring>
#include <conio.h>
using namespace std;
inline void keep_window_open() { char ch; cin>>ch; }
int main()
{
cout << "How many pennies do you have?\n";
int pennies;
cin >> pennies;
double total_pen;
total_pen = (0.01 * pennies);
if (pennies >= 1)
{
string penn = " pennies.";
}else
{
string penn = " penny.";
} cout << "How many nickles do you have?\n";
int nickles;
cin >> nickles;
double total_nic;
total_nic = (0.05 * nickles);
if (nickles >= 1)
{
string five = " nickels.";
}else
{
string five = " nickel.";
} cout << "How many dimes do you have?\n";
int dimes;
cin >> dimes;
double total_dim;
total_dim = (0.10 * dimes);
if (dimes >= 1)
{
string ten = " dimes.";
}else
{
string ten = " dime.";
} cout << "How many quarters do you have?\n";
int quarters;
cin >> quarters;
double total_qua;
total_qua = (0.25 * quarters);
if (quarters >= 1)
{
string twentyfive = " quarters.";
}else
{
string twentyfive = " quarter.";
} cout << "How many half-dollars do you have?\n";
int half_dollars;
cin >> half_dollars;
double total_dol;
total_dol = (0.50 * half_dollars);
if (half_dollars >= 1)
{
string fifty = " half dollars.";
}else
{
string fifty = " half dollar.";
}
string saying = "You have ";
cout << saying pennies penn << "\n" << saying nickles five << "\n" << saying dimes ten << "\n" << saying quarters twentyfive << "\n" << saying half_dollars fifty << "\n";
keep_window_open()
return 0;
}