My first C++ program.
Yay me.
Code:
//************************************************** *******
//* *
//* CIS 233.01 Program Lab 1: Chapter 3, Ex 4 (Pg 143) *
//* Written by: George Perley *
//* Date: April 18, 2005 *
//* *
//************************************************** *******
#include <iostream> // Must include for cin and cout
#include <fstream> // Must include for file input and output functions
#include <iomanip> // Must include for setw , fixed and setprecision functions
using namespace std; // This is so the program knows how to use cin and cout
int main() // Start of main function
{
const double taxableAmountRate = .92; // Set constant for amount of assesed value that is taxable
const double taxRate = 1.05; // Set constant for tax per $100 of taxable value
double assesedValue; // declare variable for assesed value of property
double taxableAmount; // declare variable for caluclated taxable value of property
double propertyTax; // declare variable for calculated property tax amount
ofstream fout; // declare file output command
fout.open("Lab1OutputFile.txt"); // open text file
cout << "Please enter the assesed value of the property: "; // Prompt user for assesed value
cin >> assesedValue; // Get assesed value input from user
cout << endl; // carriage return before displaying results
taxableAmount = assesedValue * taxableAmountRate; // Calculate taxable portion of proprety value
propertyTax = (taxableAmount / 100) * taxRate; // Calculate property tax
cout << setfill(' '); // set fill to blank spaces for formatting of output to screen
cout << fixed << showpoint << setprecision(2); // desplay numbers on screen in two digit decimal notation.
cout << left << "Assessed Value: " << setw(25) << right << assesedValue << endl; // Screen output
cout << left << "Taxable Amount: " << setw(25) << right << taxableAmount << endl; // Screen output
cout << left << "Tax Rate for each $100.00: " << setw(14) << right << taxRate << endl; // Screen output
cout << left << "Property Tax: " << setw(27) << right << propertyTax << endl; // Screen output
cout << endl;
fout << setfill(' '); // set fill to blank spaces for formatting of output to file
fout << fixed << showpoint << setprecision(2); // display numbers in file in two digit decimal notation.
fout << left << "Assessed Value: " << setw(25) << right << assesedValue << endl; // Write to file
fout << left << "Taxable Amount: " << setw(25) << right << taxableAmount << endl; // Write to file
fout << left << "Tax Rate for each $100.00: " << setw(14) << right << taxRate << endl; // Write to file
fout << left << "Property Tax: " << setw(27) << right << propertyTax << endl; // Write to file
fout.close(); // close file
} // This is the end of the main function, and my program