ADDITION PROGRAM
#include <iostream.h>
main()
{
int a,b,c;
cout << "What is the value of a? ";
cin >> a;
cout << "What is the value of b? ";
cin >> b;
cout << "What is the value of c? ";
cin >> c;
cout << "The value of a + b + c is ";
cout << a + b + c <<"." << '\n';
cout << "By: Kenny Van Alstyne";
return 0;
}
----------------------------------------------------------------------------
AIRPLANE PROJECT
#include <iostream.h> // header file for cout and cin //
#include <iomanip.h> // header file for setprecision //
main() // begin the program //
{
// constants to set specifications for a Boeing 747-400 //
// Source: The World Almanac and Book of Facts 1995 //
char const plane_name[] = "Boeing 747-400";
int const plane_speed = 533;
int const number_of_seats = 398;
int const max_flight_length = 4331;
int const cost_per_hour = 6939;
int num_pass; // number of passengers on the plane //
float num_miles; // flight distance //
float avg_ticket_price; // average ticket price for flight //
float flight_cost; // cost for the flight //
float cost_per_pass; // cost per passenger //
float total_fares; // total fares collected for the flight //
float profit; // profit for the flight //
float hours; // length of the flight in hours //
cout << "\nAIRLINE FLIGHT ANALYSIS\n";
cout << "Airplane name: " << plane_name << endl;
cout << "Enter the number of passengers on the flight (maximum "
<< number_of_seats << "): ";
cin >> num_pass;
cout << "Enter the distance (in miles) of the flight (maximum "
<< max_flight_length << "):";
cin >> num_miles;
cout << "Enter the average ticket price: $";
cin >> avg_ticket_price;
hours = num_miles / plane_speed; // calculate time reuired for flight //
flight_cost = hours * cost_per_hour; // calculate cost of flight //
cost_per_pass = flight_cost / num_pass; // calculate cost per passenger //
total_fares = num_pass * avg_ticket_price; // calculate total fares //
profit = total_fares - flight_cost; // calculate total profit //
cout.setf(ios::showpoint); // force decimal point to be displayed //
cout.setf(ios::fixed); // prevent scientific notation //
cout << "\nAnalysis for " << plane_name << endl;
cout << "\nThe flight will take approximately " << setprecision(2)
<< hours << " hours.\n";
cout << "The cost of the flight will be $" << flight_cost
<< ", with a \n";
cout << "cost per passenger of $" << cost_per_pass << ".\n";
cout << "The total fares collected from ticket sales is $"
<< total_fares << ",\n";
cout << "resulting in a profit of $" << profit << ".\n";
cout << "By: Kenny Van Alstyne";
return 0;
}
-------------------------------------------------------------------------------------------------
CHECK YOUR BALANCE
#include<iostream.h>
main()
{
char name[30];
float bbalance;
float cheque;
float deposit1;
float deposit2;
float deposit3;
float deposit4;
float fees;
float balance;
cout << "What is your name? ";
cin.get(name, 30);
cin.ignore(80, '\n');
cout << "What is your beginning balance? $";
cin >> bbalance;
cout << "What is the total checks for the month? $";
cin >> cheque;
cout << "What is the deposit for the first week? $";
cin >> deposit1;
cout << "What is the deposit for the second week? $";
cin >> deposit2;
cout << "What is the deposit for the third week? $";
cin >> deposit3;
cout << "What is the deposit for the fourth week? $";
cin >> deposit4;
cout << "What were the service fees? $";
cin >> fees;
balance = (bbalance + (deposit1 + deposit2 + deposit3 + deposit4)) -
(cheque + fees);
cout << name << "'s balance is $" << balance << ". \n";
cout << "By: Kenny Van Alstyne.";
return 0;
}
--------------------------------------------------------------------------------------------
BUDGET PROJECT
#include <iostream.h>
main()
{
const char ERROR = '\O';
int choice;
float income;
float item = 0;
float total;
float left;
char name[30];
cout << "What is your name? ";
cin.get(name, 30);
cin.ignore(80, '\n');
cout << "What is your monthly income? ";
cin >> income;
do
{
cout << "Choose from the following for your bills...\n";
cout << "1 - Renting House - $550\n";
cout << "2 - Owning House - $750\n";
cout << "3 - Electricity - $150\n";
cout << "4 - Gas - $45\n";
cout << "5 - Water - $35\n";
cout << "6 - Basic Cable\n";
cout << "7 - Expanded Cable - $90\n";
cout << "8 - Lexus - $450\n";
cout << "9 - Z71 - $350\n";
cout << "10 - Cell Phone - $50\n";
cout << "Enter 11 When You Are Complete!\n";
cin >> choice;
switch(choice)
{
case 1:
item = item + 550;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 2:
item = item + 750;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 3:
item = item + 150;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 4:
item = item + 45;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 5:
item = item + 35;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 6:
item = item + 45;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 7:
item = item + 90;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 8:
item = item + 450;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 9:
item = item + 350;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 10:
item = item + 50;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 11:
total = item;
left = income - total;
cout << name <<"'s total for bills is $" << total << ". \n";
cout << "You have $" << left << " leftover money. \n";
default:
item = 0;
break;
}
}
while (choice==ERROR);
cout << "By: Kenny Van Alstyne.";
return 0;
}
--------------------------------------------------------------------------------
CAR LOT PROJECT
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#define NumEntries 5
main()
{
cout << "!Bearcat Auto! \n";
char ncar[5][20];
char mcar[5][20];
char ycar[5][20];
char pcar[5][20];
int b;
int k;
for(b=0; b<NumEntries; b++)
{
cout << "What is the name of the car? ";
cin >> ncar[b];
cout << "What is the model of the car? ";
cin >> mcar[b];
cout << "What is the year of the car? ";
cin >> ycar[b];
cout << "What is the amount of the car? ";
cin >> pcar[b];
}
cout << "Cars" << setw(20) << "Model" << setw(20) << "Year" << setw(15) <<
"Amount \n";
for(k=0; k<b; k++)
{
cout << ncar[k] << setw(20) << mcar[k] << setw(20) << ycar[k]
<< setw(15) << pcar[k] << '\n';
}
cout << "By: Kenny Van Alstyne";
return 0;
}
LANGUAGE CHANGE PROJECT
#include <iostream.h>
// begin program //
main()
{
double data;
int choice;
float dollars;
cout << "Please enter the number of dollars you would like to convert.\n";
cout << "$";
cin >> dollars;
cout << "Choose to convert from the following \n";
cout << " 1 - German Deutsche Mark \n";
cout << " 2 - Japan Yan \n";
cout << " 3 - Russian Rubbles \n";
cout << " 4 - Mexico Paco \n";
cout << ": ";
cin >> choice;
switch(choice)
{
case 1:
data = (dollars * .5412);
cout << "You converted from dollars to German Deutsche Mark.\n";
cout << "The result was " << data << ". \n";
break;
case 2:
data = (dollars * .0091);
cout << "You converted from dollars to Japan Yen.\n";
cout << "The result was " << data << ". \n";
break;
case 3:
data = (dollars * .0412);
cout << "You converted from dollars to Russian Rubbles.\n";
cout << "The result was " << data << ". \n";
break;
case 4:
data = (dollars * .9712);
cout << "You converted from dollars to Mexico Paco.\n";
cout << "The result was " << data << ". \n";
break;
default:
data = 0;
cout << "Invalid.";
break;
}
cout << "By: Kenny Van Alstyne.";
return 0;
}
------------------------------------------------------------------------------------------
CAR LOT PROJECT
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
#define NumEntries 5
main()
{
cout << "!Bearcat Auto! \n";
char ncar[5][20];
char mcar[5][20];
char ycar[5][20];
char pcar[5][20];
int b;
int k;
for(b=0; b<NumEntries; b++)
{
cout << "What is the name of the car? ";
cin >> ncar[b];
cout << "What is the model of the car? ";
cin >> mcar[b];
cout << "What is the year of the car? ";
cin >> ycar[b];
cout << "What is the amount of the car? ";
cin >> pcar[b];
}
cout << "Cars" << setw(20) << "Model" << setw(20) << "Year" << setw(15) <<
"Amount \n";
for(k=0; k<b; k++)
{
cout << ncar[k] << setw(20) << mcar[k] << setw(20) << ycar[k]
<< setw(15) << pcar[k] << '\n';
}
cout << "By: Kenny Van Alstyne";
return 0;
}
---------------------------------------------------------------------------------------------
CLOTHES PROJECT
/* Kenny Van Alstyne
October 7, 2003
Clothes */
#include <iostream.h>
#include <iomanip.h>
main()
{
const char ERROR = '\O';
int choice;
float item = 0;
float total;
do
{
cout << "Choose from the following Christmas list ...\n";
cout << "1 - Shirt - $42.00\n";
cout << "2 - Brown Belt - $25.00\n";
cout << "3 - Skirt - $20.00\n";
cout << "4 - Capris - $19.00\n";
cout << "5 - T-Shirt - $17.00\n";
cout << "6 - Shoes - $65.00\n";
cout << "7 - Black Belt - $20.00\n";
cout << "8 - Purse - $45.00\n";
cout << "Enter 9 When You Are Complete!\n";
cin >> choice;
switch(choice)
{
case 1:
item = item + 42;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 2:
item = item + 25;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 3:
item = item + 20;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 4:
item = item + 19;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 5:
item = item + 17;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 6:
item = item + 65;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 7:
item = item + 20;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 8:
item = item + 45;
cout <<"$"<<item<<'\n';
choice=ERROR;
break;
case 9:
total = item;
cout << "Your total is $"<< setprecision(3) << total << ". \n";
default:
item = 0;
break;
}
}
while (choice==ERROR);
cout << "By: Kenny Van Alstyne.";
return 0;
}
--------------------------------------------------------------------------
LANGUAGE CHANGE PROJECT
#include <iostream.h>
// begin program //
main()
{
double data;
int choice;
float dollars;
cout << "Please enter the number of dollars you would like to convert.\n";
cout << "$";
cin >> dollars;
cout << "Choose to convert from the following \n";
cout << " 1 - German Deutsche Mark \n";
cout << " 2 - Japan Yan \n";
cout << " 3 - Russian Rubbles \n";
cout << " 4 - Mexico Paco \n";
cout << ": ";
cin >> choice;
switch(choice)
{
case 1:
data = (dollars * .5412);
cout << "You converted from dollars to German Deutsche Mark.\n";
cout << "The result was " << data << ". \n";
break;
case 2:
data = (dollars * .0091);
cout << "You converted from dollars to Japan Yen.\n";
cout << "The result was " << data << ". \n";
break;
case 3:
data = (dollars * .0412);
cout << "You converted from dollars to Russian Rubbles.\n";
cout << "The result was " << data << ". \n";
break;
case 4:
data = (dollars * .9712);
cout << "You converted from dollars to Mexico Paco.\n";
cout << "The result was " << data << ". \n";
break;
default:
data = 0;
cout << "Invalid.";
break;
}
cout << "By: Kenny Van Alstyne.";
return 0;
}
------------------------------------------------------------------------------------------