ifjake

Sep 6, 2006, 12:53 PM

I'm in this introductory C++ course at college. We're using Turbo C++ (the old DOS version) to write and compile our assignments. I was wondering if there's a way to make is so I can write a C++ assignment on my Mac pretty much exactly the way I would on the PCs in the lab, able to build and test and debug from my laptop, only having to change things such as file paths and whatever else of the OS specific nature before handing in my assignment (we only have to hand in our source code and a copy of the results, printed out on paper). Below is our introductory program. I didn't write this, but I have to compile it and such, and I think this is pretty much standard for the semester of what I can expect.

/* Name: ME

COSC: 150

Program: prog1

Due Date: Sept. 7, 2006 */

/* Program Trip:

This program calculates the total cost and miles per gallon

of a vehicle, based on the miles traveled, fuel consumed,

fuel cost per gallon, and operating cost per mile.

Input: The total cost, miles traveled, total fuel consumed,

unit cost of the fuel, and operating cost per mile.

Output: The miles per gallon, total cost of the trip,

and the cost per mile. */

/* Variable Dictionary:

Miles: Total Miles Traveled

Fuel: Total gallons used

UnitFeulCost: Feul cost per gallon

UnitOperCost: Operating cost per mile

MPG: Miles per gallon

TFeulCost: Total feul cost

TOperCost: Total operating cost

TTripCost: Total trip cost

CostPerMile: Cost per mile */

#include<iostream.h>

#include<fstream.h>

#include<conio.h>

void main()

{

clrscr();

double

Miles, Fuel, UnitFuelCost, UnitOperCost, MPG, TFuelCost, TOperCost,

TTripCost, CostPerMile;

ofstream outfile;

outfile.open("c:result.dat");

//Read in the total miles and fuel

cout<<"enter the miles traveled and the gallons of fuel used "<<endl;

cin>>Miles>>Fuel;

//Calculate miles per gallon

MPG = Miles / Fuel;

//Read in the fuel cost per gallon

//and operating cost per mile.

cout<<"enter the fuel cost and operating cost "<<endl;

cin>>UnitFuelCost>>UnitOperCost;

//Calculate the total fuel cost, operating

//cost, trip cost, and cost per mile.

TFuelCost = Fuel * UnitFuelCost;

TOperCost = UnitOperCost * Miles;

TTripCost = TFuelCost + TOperCost;

CostPerMile = TTripCost / Miles;

//Print the outputs

outfile<<"\n Miles Per Gallon: "<<MPG;

outfile<<"\n Total Trip Cost: $ "<<TTripCost;

outfile<<"\n Cost Per Mile: $ "<<CostPerMile;

outfile.close();

getch();

}

Certain things I know will have to change, like the outfile.open("c:result.dat"); statement so that OS X doesn't freak out, and I'm hoping there are some kind of equivallent standard headerfiles like the one's I've included. If all else fails, maybe there's a DOS emulator out there somewhere that could somehow run Turbo C++ and somehow ... work. So if there are any ideas out there it would be very much appreciated.

/* Name: ME

COSC: 150

Program: prog1

Due Date: Sept. 7, 2006 */

/* Program Trip:

This program calculates the total cost and miles per gallon

of a vehicle, based on the miles traveled, fuel consumed,

fuel cost per gallon, and operating cost per mile.

Input: The total cost, miles traveled, total fuel consumed,

unit cost of the fuel, and operating cost per mile.

Output: The miles per gallon, total cost of the trip,

and the cost per mile. */

/* Variable Dictionary:

Miles: Total Miles Traveled

Fuel: Total gallons used

UnitFeulCost: Feul cost per gallon

UnitOperCost: Operating cost per mile

MPG: Miles per gallon

TFeulCost: Total feul cost

TOperCost: Total operating cost

TTripCost: Total trip cost

CostPerMile: Cost per mile */

#include<iostream.h>

#include<fstream.h>

#include<conio.h>

void main()

{

clrscr();

double

Miles, Fuel, UnitFuelCost, UnitOperCost, MPG, TFuelCost, TOperCost,

TTripCost, CostPerMile;

ofstream outfile;

outfile.open("c:result.dat");

//Read in the total miles and fuel

cout<<"enter the miles traveled and the gallons of fuel used "<<endl;

cin>>Miles>>Fuel;

//Calculate miles per gallon

MPG = Miles / Fuel;

//Read in the fuel cost per gallon

//and operating cost per mile.

cout<<"enter the fuel cost and operating cost "<<endl;

cin>>UnitFuelCost>>UnitOperCost;

//Calculate the total fuel cost, operating

//cost, trip cost, and cost per mile.

TFuelCost = Fuel * UnitFuelCost;

TOperCost = UnitOperCost * Miles;

TTripCost = TFuelCost + TOperCost;

CostPerMile = TTripCost / Miles;

//Print the outputs

outfile<<"\n Miles Per Gallon: "<<MPG;

outfile<<"\n Total Trip Cost: $ "<<TTripCost;

outfile<<"\n Cost Per Mile: $ "<<CostPerMile;

outfile.close();

getch();

}

Certain things I know will have to change, like the outfile.open("c:result.dat"); statement so that OS X doesn't freak out, and I'm hoping there are some kind of equivallent standard headerfiles like the one's I've included. If all else fails, maybe there's a DOS emulator out there somewhere that could somehow run Turbo C++ and somehow ... work. So if there are any ideas out there it would be very much appreciated.