1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Flura [38]
3 years ago
7

Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number

of miles and write them into a notebook. At the end of the week, they would like to know the number of miles run each day, the total miles for the week, and average miles run each day. Write a program to help them analyze their data. Your program must contain parallel arrays: an array to store the names of the runners and a two-dimensional array of five rows and seven columns to store the number of miles run by each runner each day. Furthermore, your program must contain at least the following functions: a function to read and store the runners’ names and the numbers of miles run each day; a function to find the total miles run by each runner and the average number of miles run each day; and a function to output the results. (You may assume that the input data is stored in a file and each line of data is in the following form: runnerName milesDay1 milesDay2 milesDay3 milesDay4 milesDay5 milesDay6 milesDay7.)
Computers and Technology
1 answer:
kolbaska11 [484]3 years ago
5 0

Answer:

C++ program explained below for the problem

Explanation:

// UpComingMarathon.cpp : Defines the entry point for the console application.

//header files

#include "stdafx.h" //optional

#include <iostream>

#include <cstring>

#include <fstream>

#include <iomanip>

using namespace std;

//declare the gobal array of type double

double average[5];

//declare the function prototypes

void getData(ifstream& inf, string n[], double runData[][8], int count);

void calculateAverage(double runData[][8], int count);

void print(string n[], double runData[][8], int count);

int main()

{

   string names[5];

   double runningData[5][8];

   ifstream inputfile("input.txt");

   if(inputfile)

   {

        //call the method getData

        getData(inputfile, names, runningData, 5);

   }

   else

   {

        //error message

        cout<<"Sorry! Unable to open the file."<<endl;

        system("pause");

        return 0;

   }

   //close the file

   inputfile.close();

   //call the method calculateAverage to compute the

   //average miliage of each runner

   calculateAverage(runningData, 5);

   //call display the names and their weekly run rate and their averages

   print(names, runningData, 5);

   system("pause");

   return 0;

}

//definition of method getData that reads the data from the file and

//stores the names into array n and run data into runData array

//simultaneously.

void getData(ifstream& inf, string n[], double runData[][8], int count)

{  

   while(!inf.eof())

   {

        for(int i=0;i<count; i++)

        {

            inf>>n[i];

            for(int j=0;j<7;j++)

            {

                inf>>runData[i][j];

            }

        }

   }

}

//definition of method calculateAverage that comptes the total first

//then stores the value of average into the average array

void calculateAverage(double runData[][8], int count)

{

   double total;

   for(int i=0;i<count;i++)

   {

        total=0;

        for(int j=0;j<7;j++)

        {

            total+=runData[i][j];

        }        

        average[i]=total/7;      

   }

}

//definition of method print that prints the output

//in a tabular format

void print(string n[], double runData[][8], int count)

{

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<setfill(' ');

   cout<<endl;

   cout<<"Name"<<setw(6)<<"";

   for(int i=0;i<7;i++)

        cout<<setw(7)<<"Day "<<(i+1);

   cout<<setw(12)<<"Average"<<endl;

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<setfill(' ')<<endl;

   for(int i=0;i<count;i++)

   {

        cout<<n[i]<<setw(8)<<fixed<<"";

        for(int j=0;j<7; j++)

        {

            cout<<setprecision(2)<<fixed<<runData[i][j]<<setw(3)<<"";

        }

        cout<<setw(8)<<average[i];

        cout<<endl;

   }

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<endl;

}

You might be interested in
I have tried installing "windows media player" on my computer but at a point, something disrupts its instalment or I am asked to
Minchanka [31]
Windows media player should come pre-installed on your system and does not cost anything. You likely have malware on your system. I would download Malwarebytes antimalware from here

https://www.malwarebytes.org/mwb-download/thankyou/

There is a premium version but just do the free one. Install and run. Let it get rid of the bad stuff it finds. I would also make sure you have an up to date Antivirus software and run a scan. There are plenty of good free ones if you don't have one installed already.
6 0
3 years ago
Determine the following information about each value in a list of positive integers.
german

Answer and Explanation:

Using Javascript:

test7_11_13(num){

If(num%7===0||num%11===0||num%13===0){

Console.log("yes it is a multiple of 7,11 or 13");

}

else{

Console.log("It is not a multiple of any of the numbers");

}

function(num){

var makeString= num.toString();

var splitString= makeString.split("");

var makeNumber= splitString.map(Number());

var New_number= makeNumber.reduce(function(a, b) {

return a+b};,0)

}

If(New_number%2===0){

Console.log("it's an even number");

}

else{

Console.log("it's an odd number")

}

If(num%2===0||num%3===0||num%5===0||num%7===0||num%11===0){

console.log("it's not a prime number");

}

else{

console.log("it's a prime number");

}

}

From the above we have used javascript if..else statements to test the conditions for each question and output the answer to the console using console.log(). In the last part for prime number, you could also choose to use else if statements(if,else if, else if) to test the value of the num parameter and output if it's a prime number.

8 0
3 years ago
An Organization Chart to support the Appliance Warehouse case study The SWOT Analysis diagram you performed and created to suppo
Ulleksa [173]

<u>Explanation</u>:

Remember, the aim of SWOT Analysis is to perform analysis of a phenomenon or case.

Just as in any analysis it is followed by results and recommendations based on the set rules of the analysis.

<u>The Strengths, Weaknesses, Opportunity identified and Threats can translate to the mission statement </u>of a company. It is important to know that this statement is usually factual and accurate.

3 0
3 years ago
Cell references in a formula are called _____.<br> a. assumptionsc. numbersb. valuesd. content
Airida [17]
It would bbe d because content is what is in something
7 0
4 years ago
The purpose of __________________ is to isolate the behavior of a given component of software. It is an excellent tool for softw
OLga [1]

Answer:

d.) black-box testing

Explanation:

Software testing can be regarded as procedures/process engage in the verification of a system, it helps in detection of failure in the software, then after knowing the defect , then it can be corrected. Black Box Testing can be regarded as a type of software testing method whereby internal structure as well as design of the item under test is not known by one testing it. In this testing internal structure of code/ program is unknown when testing the software, it is very useful in checking functionality of a particular application. Some of the black box testing techniques commonly used are; Equivalence Partitioning, Cause effect graphing as well as Boundary value analysis. It should be noted that the purpose of black-box testing is to isolate the behavior of a given component of software.

3 0
3 years ago
Other questions:
  • Food is shipped thousands of miles throughout our country using various types of transportation such as trucks, planes, and boat
    10·1 answer
  • Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an in
    13·1 answer
  • With Voice over Internet Protocol (VoIP), _____. a. voicemails cannot be received on the computer b. call quality is significant
    6·1 answer
  • The advancement of technology in our daily lives has changed how we interact with the world.
    10·1 answer
  • You will include code that will validate all user input. If the user inputs an invalid value, the program will respond with an e
    14·1 answer
  • Which key combination should you use
    9·2 answers
  • True or False? Security code is almost always open source!<br> True<br> False
    8·2 answers
  • Identify the correct answer in each item. Write your answer on the blank provided before
    13·1 answer
  • Help me with thissssss
    5·1 answer
  • _____ is a system in which a finite set of words can be combined to generate an infinite number of sentences.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!