User Tools

Site Tools


user:rrichar8:portfolio:project3

Project:Miles to Kilometers Conversion Program

A project in C++ Programming by RICH during the FALL SEMESTER OF 2011.

This project was begun on November 15 and was anticipated to take only a few days, but I've been working on it for the past 3 weeks now. (Upon completion you can correct this with the actual length)

Objectives

To better understand C++ programming syntax and implementation. I began this program as a very large program and have filter out everything possible to make it run efficiently and with minimum code. I was having an enormous amount of error messages with the original program when compiling it. As I began to investigate the error messages, I found that much of the code was redundant and unnecessary to accomplish what should be a very easy task in arithmetic. Seems that simplicity sometimes works better.

Prerequisites

In order to successfully accomplish/perform this project, the listed resources/experiences need to be consulted/achieved:

Background

This will be the first project I've compiled in C++..I've been having a difficult time figuring out why I'm getting error messages all the time when I compile the program in Putty. I've named and renamed the file in various endings, and I've used various commands to compile.

Scope

I'm a attempting to do this project and another project using class. I'm am attempting this one first because it has a simple code and I want to make sure that I understand the exact syntax necessary to code and compile the program and make it WORK too.

Attributes

State and justify the attributes you'd like to receive upon successful approval and completion of this project.

  • attribute1: why you feel your pursuit of this project will gain you this attribute
  • attribute2: why you feel your pursuit of this project will gain you this attribute
  • etc…

Procedure

The actual steps taken to accomplish the project. Include images, code snippets, command-line excerpts; whatever is useful for intuitively communicating important information for accomplishing the project.

Code

Upon completion of the project, if there is an applicable collection of created code, place a copy of your finished code within <code> </code> blocks here.

/*
 * compile with:
 *   g++ miles.c -o miles
 *   
 * execute with:
 *   ./miles
 */
#include <iostream>
 
using namespace std;
 
int main()
 
{
      double miles;
      double kilometers;
      const double kilometersPerMile = 1.609;
 
      cout << "Input miles: " << endl;
      cin >> miles;
 
      kilometers = kilometersPerMile * miles;
 
      cout << "Kilometers = " << kilometers << endl << endl;
 
return 0;
}

Execution

Again, if there is associated code with the project, and you haven't already indicated how to run it, provide a sample run of your code:

lab46:~/src/cprog$ g++ miles.c -o miles
lab46:~/src/cprog$ miles.c
lab46:~/src/cprog$ ./miles
Input miles:
654
Kilometers = 1052.29

lab46:~/src/cprog$

Reflection

I've learned that C++ programming is actually easier to use than C programming ONCE you learn the proper syntax and procedures to compile properly. There is a wealth of good information available to help learning the usage and syntax online.

References

user/rrichar8/portfolio/project3.txt · Last modified: 2011/12/03 23:15 by rrichar8