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

Arrays_Follow every instructions for a positive rating and to receive 300 points

ID: 3772736 • Letter: A

Question

Arrays_Follow every instructions for a positive rating and to receive 300 points

This is a_Beginner Level_Intro to C++

USE basic and simple syntax_beginner level

(1)

- do NOT use multi-dimensional arraays
- do NOT use global variables

- do NOT use libraries outside the knowledge of the student curriculum

- do NOT use std::cout
(2)
- Maximum number of elements in array is 10
- Input values in inches = type int
- Values in meters and yard = type double
(3)
- Add comments
- Create functions mentioned in the question
- and you MAY create other functions
(4)
- Your Output should match: the Sample Output on the right side of the question
- 20% Followed Instructions
- 30% Coding (Program setup, organization, easy to read, white spaces, variables & function naming, loops organization, indentation)
- 10% Input & Output
- 20% Design of function and function invocation
- 20% Correctness

(5)

Libraries covered in class are:

#include <iostream> using namespace std;

#include <fstream>

#include <string>

#include <cstdlib>

#include <cmath>

#include <iomanip>

#include <cassert>

#include <conio.h>

Libraries covered in class are:

#include <iostream> using namespace std;

#include <fstream>

#include <string>

#include <cstdlib>

#include <cmath>

#include <iomanip>

#include <cassert>

#include <conio.h>

Explanation / Answer

#include <iostream>
using namespace std;

//This function takes number of items as an
//input and then takes those many inputs in
//inches array.

int getInfo(int inches[], int count)
{
   cout << "enter the number of items" << endl;
   cin >> count;
   cout << "enter the inches" << endl;
   for (int i = 0; i < count; i++)
   {
       cin >> inches[i];
   }
   return count;
}

//This function prints the inches array
void display(int inches[], int count)
{
   for (int i = 0; i < count; i++)
   {
       cout << inches[i] << endl;
   }
   cout << endl;
}

//This function prints the meters and yards array
void display(double arr[], int count)
{
   for (int i = 0; i < count; i++)
   {
       cout << arr[i] << endl;
   }
   cout << endl;
}

//This function converts the inches to meters
void toMeters(int inches[], int count, double meters[])
{
   for (int i = 0; i < count; i++)
   {
       meters[i] = inches[i] * 39.3700787;
   }
}

//This function converts the inches to yards
void toYards(int inches[], int count, double yards[])
{
   for (int i = 0; i < count; i++)
   {
       yards[i] = inches[i] * 36;
   }
}

int main()
{
   int count=0;
   int inches[10];
   double meters[10];
   double yards[10];

   count=getInfo(inches, count); //taking inout from the user and returning back the number of items added to inches array

   toMeters(inches, count, meters); //Converting each item of inches array to meters
   toYards(inches, count, yards);   //Converting each item of inches array to yards

   cout << "Original list in inches:" << endl;
   display(inches, count);

   cout << "Values in meters:" << endl;
   display(meters, count);

   cout << "Values in yards:" << endl;
   display(yards, count);
   system("pause");
   return 0;
}

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