View Single Post
  #1  
Old April 20th, 2005, 12:30 PM
geoschmo's Avatar

geoschmo geoschmo is offline
National Security Advisor
 
Join Date: Jan 2001
Location: Ohio
Posts: 8,450
Thanks: 0
Thanked 4 Times in 1 Post
geoschmo is on a distinguished road
Default OT: Look what I can do...

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

__________________
I used to be somebody but now I am somebody else
Who I'll be tomorrow is anybody's guess
Reply With Quote