.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
winSPMBT: Main Battle Tank- Save $6.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #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
  #2  
Old April 20th, 2005, 12:39 PM
General Woundwort's Avatar

General Woundwort General Woundwort is offline
Lieutenant Colonel
 
Join Date: Nov 2001
Location: Virginia
Posts: 1,311
Thanks: 0
Thanked 0 Times in 0 Posts
General Woundwort is on a distinguished road
Default Re: OT: Look what I can do...

Interested in doing my Python homework?
Reply With Quote
  #3  
Old April 20th, 2005, 01:09 PM
DarkHorse's Avatar

DarkHorse DarkHorse is offline
Sergeant
 
Join Date: Dec 2002
Location: U.S.A
Posts: 311
Thanks: 1
Thanked 0 Times in 0 Posts
DarkHorse is on a distinguished road
Default Re: OT: Look what I can do...

That can't be right. I don't see "hello world" anywhere in that code.
__________________
Vogon ships are yellow chunky slablike somethings, huge as office buildings, silent as birds. They hang in the air in much the same way that bricks don't.
(R.I.P. Douglas Adams)

-War is peace -Freedom is slavery -Ignorance is strength

In peace there's nothing so becomes a man as modest stillness and humility.
- W. Shakespeare (Henry V)
Reply With Quote
  #4  
Old April 20th, 2005, 01:16 PM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Look what I can do...

Yeah, that program is all wrong.
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #5  
Old April 20th, 2005, 02:15 PM
Combat Wombat's Avatar

Combat Wombat Combat Wombat is offline
Lieutenant Colonel
 
Join Date: Jan 2004
Location: Minnesota/South Dakota
Posts: 1,439
Thanks: 3
Thanked 3 Times in 3 Posts
Combat Wombat is on a distinguished road
Default Re: OT: Look what I can do...

I don't believe you can legally have a first C++ program without it including "Hello World".
__________________
You can give a man fire and he will be warm for a day but set him on fire and he will be warm for the rest of his life.

A* Se+++ GdQ $? Fr! C* Css Sf-- Ai% Au M+++ Mp* S@ Ss++++ RNSHP Pw++ Fq+++ Nd++ Rp++ G++++ Mm++ Bb+++@ L+ Tcp--
Get the newest Version of Invasion! here: http://www.secenter.org/

Reply With Quote
  #6  
Old April 20th, 2005, 02:45 PM
Aiken's Avatar

Aiken Aiken is offline
Major
 
Join Date: Jan 2004
Location: Taganrog, Russia
Posts: 1,087
Thanks: 0
Thanked 0 Times in 0 Posts
Aiken is on a distinguished road
Default Re: OT: Look what I can do...

It only means that geo's really first programm was written in Basic.
But he will never admit it
Reply With Quote
  #7  
Old April 21st, 2005, 05:00 AM
Strategia_In_Ultima's Avatar

Strategia_In_Ultima Strategia_In_Ultima is offline
Major General
 
Join Date: Jan 2005
Location: In your mind.
Posts: 2,241
Thanks: 0
Thanked 0 Times in 0 Posts
Strategia_In_Ultima is on a distinguished road
Default Re: OT: Look what I can do...

What is spagetti code/a "Hello World" program?
__________________
O'Neill: I have something I want to confess you. The name's not Kirk. It's Skywalker. Luke Skywalker.
-Stargate SG1
Reply With Quote
  #8  
Old April 21st, 2005, 05:06 AM
Will's Avatar

Will Will is offline
Lieutenant Colonel
 
Join Date: Mar 2001
Location: Emeryville, CA
Posts: 1,412
Thanks: 0
Thanked 0 Times in 0 Posts
Will is on a distinguished road
Default Re: OT: Look what I can do...

Quote:
Strategia_In_Ultima said:
What is spagetti code/a "Hello World" program?
Spaghetti code is exactly what it sounds like. It's stringy, messy, and gets all over the place. It's hard to pick it up, and you would in general just be better off cutting it into smaller pieces that are easier to deal with. So, like SJ's early program, full of GOTO statements, etc, instead of using "nice" loop structures, functions, and other things that make writing and reading programs easier.

"Hello World" is the traditional first program. All it does is output the text "Hello World" to standard output, then exits.
__________________
GEEK CODE V.3.12: GCS/E d-- s: a-- C++ US+ P+ L++ E--- W+++ N+ !o? K- w-- !O M++ V? PS+ PE Y+ PGP t- 5++ X R !tv-- b+++ DI++ D+ G+ e+++ h !r*-- y?
SE4 CODE: A-- Se+++* GdY $?/++ Fr! C++* Css Sf Ai Au- M+ MpN S Ss- RV Pw- Fq-- Nd Rp+ G- Mm++ Bb@ Tcp- L+
Reply With Quote
  #9  
Old April 21st, 2005, 08:28 AM
NullAshton's Avatar

NullAshton NullAshton is offline
Major General
 
Join Date: Nov 2004
Location: Floating in space.
Posts: 2,297
Thanks: 0
Thanked 0 Times in 0 Posts
NullAshton is on a distinguished road
Default Re: OT: Look what I can do...

The 500 or so lines of spagetti code was my first time creating a fairly good program. It was "Guess the Animal", kinda like twenty questions where the computer will ask you a question, and you answer it. It did very good, and would even learn from its mistakes I even implimented a save and load feature, complete with my own file type! And it had a nice blue background
__________________
Hey! I found squirrels!

Vala - "The last time I was this bored, I took hostages!"
Reply With Quote
  #10  
Old April 21st, 2005, 09:15 AM
David E. Gervais's Avatar

David E. Gervais David E. Gervais is offline
General
 
Join Date: May 2002
Location: Canada
Posts: 3,227
Thanks: 7
Thanked 44 Times in 28 Posts
David E. Gervais is on a distinguished road
Default Re: OT: Look what I can do...

aaaahm so we are taking a walk down memory lane and sharing our 'First' Programming experience..

For me it was Atari Basic on the Atari 800 Computer. Aaah, the good old ways of line numbering and GOTO, GOSUB.. But the Atari let you place multiple commands on one line so you could cheat.

On the PC My first programming was with GW-Basic which came with the computer and I eventually graduated to Quick Basic 4.5 which allowed me to 'compile executables' allthough it was still an interpreted language when coding.

I'm still waiting for an 'Interpreted C language, I hate having to code, compile, run, code compile run,.. I miss the code, run, code, run, compile, share method.

nuf said, Cheers!
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 02:27 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2024, Shrapnel Games, Inc. - All Rights Reserved.