Hi all. I am very new at this stuff; first C++ Programming class with no background whatsoever. We are asked to create the design work and coding to generate an invoice given certain criteria. I wrote the program using the info and directives provided but I am coming up with 5 errors in the compiler that I cannot seem to correct [nor know how to do.] Please see below and let me know if anyone can provide any help. I am using a d/l C++ compiler from DEV-C++. A million and one thanks. -R

//**********Preprocessor Directives**********

#include <iostream>
#include <iomanip>
#include <string>
#include <stdio.h>

//**********main**********
int main()
{
  char          date[30],           // Today's date
                name[30],           // Customer's First and Last Name
                item[30];           // Item Description  
                
  const float   base_cost = 50.00,  // base cost of rental
                cost_daily = 5.00;  // daily cost of rental
  
  int           n_days;             // number of days
                      
  float         rental_cost,        // base_cost + [cost_daily x n_days]
                tax,                // rental_cost * .07
                total_cost,         // rental_cost + tax
                sec_dep,            // total_cost * .10
                bal_due;            // total_cost - sec_dep
              
                                         // input section
  cout << "Enter today's date:  "; 
  cin.getline(date,sizeof(date));
  cout << "Enter Customer Name:  ";
  cin.getline(name, sizeof(name));
  cout << "Enter item description:  ";
  cin.getline(item, sizeof(item));
  cout << "Enter base cost:  ";
  cin >> base_cost;
  cout << "Enter daily cost:  ";
  cin >> cost_daily;
  cout << "Enter number of rental days:  ";
  cin >> n_days;

                                       // process
  rental_cost = base_cost + (cost_daily * n_days)
  tax = rental_cost * .07
  total_cost = rental_cost + tax
  sec_dep = total_cost * .10
  bal_due = total_cost - sec_dep
  
                                      // program output
system ("cls");
  cout << "Invoice for Hillside All-Rental" << endl;
  cout << "===============================" << endl << endl;
  cout << "Today's Date:  " << date << endl;
  cout << "Name:   " << name << endl;
  cout << "Item:  " << item << endl;
  cout << "Number of Rental Days:  " << n_days << endl;
  cout << "Rental Cost:  " << base_cost + (cost_daily * n_days) << endl;
  cout << "Tax:  " << rental_cost * .07 << endl;
  cout << "Total Cost:  " << rental_cost + tax << endl;
  cout << "Security Deposit:  " << total_cost - sec_dep << endl;
  cout << "Balance Due:  " << total_cost - sec_dep << endl;

return 0;
}

Compiler Reads:
Compiler: Default compiler
Executing g++.exe...
g++.exe "\\Filer1\udata\rharvison\CIS165\hillside.cpp" -o "\\Filer1\udata\rharvison\CIS165\hillside.exe" -I"C:\Dev-Cpp\include\c++\3.3.1" -I"C:\Dev-Cpp\include\c++\3.3.1\mingw32" -I"C:\Dev-Cpp\include\c++\3.3.1\backward" -I"C:\Dev-Cpp\lib\gcc-lib\mingw32\3.3.1\include" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
//Filer1/udata/rharvison/CIS165/hillside.cpp: In function `int main()':
//Filer1/udata/rharvison/CIS165/hillside.cpp:33: error: `cout' undeclared
(first use this function)
//Filer1/udata/rharvison/CIS165/hillside.cpp:33: error: (Each undeclared
identifier is reported only once for each function it appears in.)
//Filer1/udata/rharvison/CIS165/hillside.cpp:34: error: `cin' undeclared (first
use this function)

//Filer1/udata/rharvison/CIS165/hillside.cpp:48: error: syntax error before `='
token
//Filer1/udata/rharvison/CIS165/hillside.cpp:55: error: `endl' undeclared
(first use this function)

//Filer1/udata/rharvison/CIS165/hillside.cpp:68:2: warning: no newline at end of file

Execution terminated

cin and cout are part of the standard namespace. Early on, use this:

using namespace std; // after the #includes

Since you

cin >> base_cost;

you shouldn't make it const.

float base_cost = 50.00, // base cost of rental

Statements end in a semicolon.

rental_cost = base_cost + (cost_daily * n_days);
tax = rental_cost * .07;
total_cost = rental_cost + tax;
sec_dep = total_cost * .10;
bal_due = total_cost - sec_dep;

Thanks so much for getting back to me so quickly. I will try to do what you said. Hope you don't mind if I keep your email address??? You're great! Again, thanks. -R

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.