Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Written by: Fredi Garcia
- //Assignment: In Class Final
- //Class: CoSci 243
- //Date: 6/1/2017
- //Description: This program takes in measurements in inches that are input by the user
- // the program then runs through three functions that output to the screen the
- // conversions to meters and yards
- #include <iostream>
- using namespace std;
- void description();//description
- void getInfo (int a[], int& num);//get input
- void displayInches (int a[], int num);//displays inches
- void displayMeters (int a[], int num, double& meters);//displays meters
- void displayYards (int a[], int num, double& yards);//displays yards
- int main()
- {
- int measurements[10];
- int inches, spacesUsed;
- double meters, yards;
- description();//calling description
- getInfo(measurements, spacesUsed);//getting the inout
- displayInches(measurements, spacesUsed);//invoking the inches to be displayed
- cout.setf(ios::fixed);
- cout.setf(ios::showpoint);
- cout.precision(4);
- displayMeters(measurements, spacesUsed, meters);//invoking to show meters
- displayYards (measurements, spacesUsed, yards);//invoking to show yards
- return 0;
- }
- void description()//description
- {
- cout << "This program will allow you to convert inches to meters and yards.\n";
- }
- void getInfo (int a[], int& num)//gets inches
- {
- int inches;
- num = 0;
- cout << "\nPlease enter up to ten measurements in inches. (when you are done enter -1)\n";
- while (inches >= 0 && num < 10)
- {
- cin >> inches;
- a[num] = inches;
- num++;
- }
- }
- void displayInches (int a[], int num)//displays the input
- {
- cout << "\n\nValues in inches:\n";
- for (int i = 0; i < num-1; i++)
- cout << endl << a[i];
- }
- void displayMeters (int a[], int num, double& meters)//converts inches to meters and outputs
- {
- cout << "\n\nValues in meters:\n";
- for (int i = 0; i < num-1; i ++)
- {
- meters = (a[i]/39.3700787);
- cout << endl << meters;
- }
- }
- void displayYards(int a[], int num, double& yards)//converts inches to yards and outputs
- {
- cout << "\n\nValues in yards:\n";
- for (int i = 0; i < num - 1; i++)
- {
- yards = (a[i]/36);
- cout << endl << yards;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement