Question

Redo Quiz 1, but this time, you will first record your raw data onto a spreadsheet....

Redo Quiz 1, but this time, you will first record your raw data onto a spreadsheet. The C++ program is to read from the spreadsheet, calculate the average height, and output a summary of the results onto either a .txt or .rft file. The summary should only include the average height and the appropriate sport. Please make sure the average height is whole numbers and is in feet and inches.

What you will submit (zip file) on iLearn

-source code

-raw data (spreadsheet)

-output text/rtf file

0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ Program:-

#include<iostream>
#include<fstream>
#include<sstream>
using namespace std;
int main(){
   string line;
   float sum=0;
   int avg =0;
   ifstream myfile("AverageHeight.csv");           //Opening the file to read using input stream object
   ofstream outfile("a.txt");                               // Opening the file to write using ooutput fstream object
   //Checking file is present and opening or not.
   if(myfile.is_open()){
       //Reading file line by line
       while(getline(myfile,line)){
           //Creating object of stringstream by using line as argument
           stringstream s(line);
           float num;
           //extracting the value from s to num
           s>>num;
           sum += num;       //Calculating sum of heights
          
       }
   }
   avg = sum/10;       // Calculating average height
   int feet=0,inches=0;
   //Converting average height to feet and inch
   feet = avg/12;      
   inches=avg%12;
   //Writing average height to output(a.txt) file
   outfile<<feet<<"ft and "<<inches<<"in"<<endl;
   //Writing appropriate sport
   if(avg<=54){
       outfile<<"This group is better suited to be group of jockeys"<<endl;
   }else if(avg >54 && avg <79){
       outfile<<"This group is better suited to be an MLB Team"<<endl;
   }else{
       outfile<<"This group is better suited to be an NBA Team"<<endl;
   }
   //Closing input and output streams
   myfile.close();
   outfile.close();
   return 0;
}

INPUT FILE (AverageHeight.csv)

cat AverageHeight.csv

23

45

67

54

67

89

32

12

32

45

67

87

23

45

65

34

OUTPUT FILE(a.txt):

g++ Measurement.cpp

./a.out

cat a.txt

6ft and 6in

This group is better suited to be an MLB Team

Note:- Mine is Mac Pc so i texted the input and output files

Add a comment
Know the answer?
Add Answer to:
Redo Quiz 1, but this time, you will first record your raw data onto a spreadsheet....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java...

    For this assignment, you will use your knowledge of arrays and ArrayLists to write a Java program that will input a file of sentences and output a report showing the tokens and shingles (defined below) for each sentence. Templates are provided below for implementing the program as two separate files: a test driver class containing the main() method, and a sentence utilities class that computes the tokens and shingles, and reports their values. The test driver template already implements accepting...

  • Project 3 Instructions 1. Due Date & Time: 09-26-2020 at 11:59 PM WHAT TO SUBMIT Submit...

    Project 3 Instructions 1. Due Date & Time: 09-26-2020 at 11:59 PM WHAT TO SUBMIT Submit 1 zip file containing 4 files below to iLearn by the deadline. [30 points] ● 3 JAVA Files: TableBmiPro.java, MyOwnIdea.java. DiceRoll.java [24 points] ● 1 File: Make a document that shows the screen captures of execution of your programs and learning points in Word or PDF. Please make sure you capture at least 2 executions for 1 program, so 6 screen captures and one...

  • Question I This question carries 20% of the marks for this assignment. You are asked to...

    Question I This question carries 20% of the marks for this assignment. You are asked to develop a set of bash shell script: Write a script that asks for the user's salary per month. If it is less or equals to 800, print a message saying that you need to get another job to increase your income, what you earn is the Minim living cost. If the user's salary is higher than 800 and below 2000, print a message telling...

  • 1. Write a C++ program that reads daily weather observation data from a file and writes...

    1. Write a C++ program that reads daily weather observation data from a file and writes monthly and annual summaries of the daily data to a file. a. The daily weather data will be contained in a file named wx_data.txt, with each line of the file representing the weather data for a single day. b. For each day, the date, precipitation amount, maximum temperature, and minimum temperature will be provided as tab-separated data with the following format: 20180101 0.02 37...

  • Project 2 Sorting, CPU Time, and Big O Analysis Note: you will be using Microsoft Visual...

    Project 2 Sorting, CPU Time, and Big O Analysis Note: you will be using Microsoft Visual Studios 2019 as the compiler. This is an individual assignment. You will have lab time to work on this assignment as well as homework time. Each person will analyze two sorts. The first sort will be either bubble sort or insertion sort. The second sort will be either quick sort or merge sort. Create two projects, one for each sort in the given choices....

  • Mountain Paths (Part 1) Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e...

    Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...

  • Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures...

    Mountain Paths (Part 1) in C++ Objectives 2d arrays Store Use Nested Loops Parallel data structures (i.e. parallel arrays … called multiple arrays in the zyBook) Transform data Read from files Write to files structs Code Requirements Start with this code: mtnpathstart.zip Do not modify the function signatures provided. Do not #include or #include Program Flow Read the data into a 2D array Find min and max elevation to correspond to darkest and brightest color, respectively Compute the shade of...

  • Python coding exercise: please include comments Goal #1: import financial data given into your pr...

    Python coding exercise: please include comments Goal #1: import financial data given into your program provided to you as a CSV formatted text file Use the following data for testing (the following is only a sample of the data; there are over 4000 rows of data): *Note: The data you will read in is linear by date (but, non-contiguous due to holidays and weekends,) reflecting a timeline of stock performance in chronological order; however your program should run through the...

  • Python coding exercise: please include comments Goal #1: import financial data given into your program provided...

    Python coding exercise: please include comments Goal #1: import financial data given into your program provided to you as a CSV formatted text file Use the following data for testing (the following is only a sample of the data; there are over 4000 rows of data): *Note: The data you will read in is linear by date (but, non-contiguous due to holidays and weekends,) reflecting a timeline of stock performance in chronological order; however your program should run through the...

  • cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having...

    cs55(java) please Part 1: You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task. Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT