Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi, this might look a little messy. I\'m stuck, basically. Here is my NEW progra

ID: 3654699 • Letter: H

Question

Hi, this might look a little messy. I'm stuck, basically. Here is my NEW program, I will list the errors at the end. Any help would be amazing!

----------------------------------------------------------------------------------------------------------------------

/*

This program reads in a length yards, feet and inches,
and converts to meters and centimeters.
*/

#include <cmath>
#include <cstdlib>
#include <iostream>

using namespace std;
-------------------------------------------PROTOTYPES--------------------------------------------



// FUNCTION PROTOTYPE FOR read_us_length
int read_us_length(int yards,int feet,int inches);

// FUNCTION PROTOTYPE FOR convert2inches
int convert2inches(int yards,int feet,int inches);

// FUNCTION PROTOTYPE FOR convert2metric
int convert2metric(int total_inches,int meters,int centimeters);

// FUNCTION PROTOTYPE FOR write_metric_length
int write_metric_length(int meters,int centimeters);

------------------------------------MAIN FUNCTION----------------------------------------------




int main()
{
int yards, feet, inches; // length in yards, feet and inches
int total_inches; // total length in inches
int meters, centimeters; // length in meters and centimeters

read_us_length(yards, feet, inches);
total_inches = convert2inches(yards, feet, inches);
convert2metric(total_inches, meters, centimeters);
write_metric_length(meters, centimeters);

return 0;
}
------------------------------------------------------FUNCTION DEFINITIONS------------------------------------
// DEFINE FUNCTION read_us_length HERE:
int read_us_length(int yards,int feet,int inches)
{
cout<<"FOR READING LENGTHS: ";
cout<<"Enter yards: ";
cin>>yards;
cout<<"Enter feet: ";
cin>>feet;
cout<<"Enter inches: ";
cin>>inches;

if (yards<0)
{
cerr<<"Yards cannot be negative!"<<endl;

}
else if (feet<0)
{
cerr<<"feet cannot be negative!"<<endl;

}
else if (inches<0)
{
cerr<<"inches cannot be negative!"<<endl;
return read_us_length;
}

}

---------------------------------------------------------------------------------------------------------------------
// DEFINE FUNCTION convert2inches HERE:
int convert2inches(int yards,int feet,int inches)
{
int total_inches;
total_inches=yards * 36 + feet * 12 + inches;
return convert2inches;
}

----------------------------------------------------------------------------------------------------------------------
// DEFINE FUNCTION convert2metric HERE
int convert2metric(int total_inches,int meters,int centimeters)
{
centimeters = total_inches*2.54;
meters = centimeters/100;
return convert2metric;
}

---------------------------------------------------------------------------------------------------------------------
// DEFINE FUNCTION write_metric_length HERE:
int write_metric_length(int meters,int centimeters)
{
cout<<"Number of Centimeters: "<<centimeters<<endl;
return centimeters;
cout<<"Number of Meters: "<<meters<<endl;
return meters;
cout<<"FOR centimeters (B): "<<convert2metric<<endl;

}
------------------------------------------ERRORS-------------------------------------------------------------


g++ convert2metric.cpp
convert2metric.cpp: In function

Explanation / Answer

/* This program reads in a length yards, feet and inches, and converts to meters and centimeters. */ #include //#include //#include using namespace std; // FUNCTION PROTOTYPE FOR read_us_length void read_us_length(int &yards,int &feet,int &inches); // FUNCTION PROTOTYPE FOR convert2inches int convert2inches(int yards,int feet,int inches); // FUNCTION PROTOTYPE FOR convert2metric void convert2metric(int total_inches,int &meters,int ¢imeters); //changed to void // FUNCTION PROTOTYPE FOR write_metric_length void write_metric_length(int meters,int centimeters);//changed to void //------------------------------------------------------------------------------------MAIN CANNOT BE ALTERED--------------------------------------- int main() { int yards, feet, inches; // length in yards, feet and inches int total_inches; // total length in inches int meters, centimeters; // length in meters and centimeters read_us_length(yards, feet, inches); total_inches = convert2inches(yards, feet, inches); convert2metric(total_inches, meters, centimeters); write_metric_length(meters, centimeters); return 0; } // DEFINE FUNCTION read_us_length HERE: void read_us_length(int &yards,int &feet,int &inches) { //a misplaced } and returning wrong variable cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote