Question

Could someone help me out here assignment due tonight. Thank you. Develop and run problem 03...

Could someone help me out here assignment due tonight. Thank you.

Develop and run problem 03 page 231. Make a function to output your results. Read the following data into your program from a text file that you make. (Use the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, and 189.) Hint: to make a file use notepad++ input and save the file as a text file.


c++


0 0
Add a comment Improve this question Transcribed image text
Answer #1
//note: you should give the correct file path in ifstream.
if code and the file are in same folder just give filename

#include <fstream>
#include<iostream>
using namespace std;
int main() {
   //initialie the array size
   int arr[30];
   ifstream is("enter a file name");
   int cnt= 0;
   int x;
   // check that array is not already full
   while (cnt < arr[30] && is >> x)
   // and read integer from file
   arr[cnt++] = x;
   // print the integers stored in the array
   cout<<"The integers are:"<<"\n";
   for (int i = 0; i < cnt; i++) {
      cout << arr[i] <<' ';
   }
   //close the file
   is.close();
}
Add a comment
Know the answer?
Add Answer to:
Could someone help me out here assignment due tonight. Thank you. Develop and run problem 03...
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
  • written in c++ Write a program that reads a file consisting of students’ test scores in...

    written in c++ Write a program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data:76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149,...

  • This needs to be linux compatible in C++ code. Write a program that reads a file...

    This needs to be linux compatible in C++ code. Write a program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167,...

  • codeblock c++ language Write a program that reads students test scores in the range 0-200 from...

    codeblock c++ language Write a program that reads students test scores in the range 0-200 from a file until end of file (use e of() to check if ifstream reaches the End of File Stream) and store those scores in an array. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100- 124, 125–149, 150-174, and 175–200. Finally, the program outputs the total number of students, each score range...

  • This is a revision of a previous exercise, here is the question: Perform exercise 4 at...

    This is a revision of a previous exercise, here is the question: Perform exercise 4 at the end chapter 8 of your textbook using dynamic arrays. (This time the program must use dynamic arrays). I have regular array version posted below. C++: Write a program that reads a file consisting of students’ test scores in the range 0-200. It should then determine the number of students having scores in each of the following ranges: 0-24, 25-49, 50-74, 75-99, 100-124, 125-149,...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • Consider the compressive strength data 6-2. What propotion of thespecimens exhibit compressive strength of at least...

    Consider the compressive strength data 6-2. What propotion of thespecimens exhibit compressive strength of at least 1379 KN/m^2? ■ TABLE 62 Compressive Strength (in psi) of 80 Aluminum-Lithium Alloy Specimens 105 97 245 163 207 134 218 199 160 196 221 154 228 131 180 178 157 151 175 201 183 153 174 154 190 76 101 142 149 200 186 174 199 115 193 167 121 120 181 160 194 184 165 145 160 150 181 168 158 208...

  • Please help me with this problem urgently. Please provide the solution both mathematically and in R...

    Please help me with this problem urgently. Please provide the solution both mathematically and in R code 3.21 The data in Table 3.8 consist of head measurements on first and second sons (Frets 1921). Define yi and y2 as the measurements on the first son and xi and 2 for the second son. (a) Find the mean vector for all four variables and partition it into ( as in (3.41). (b) Find the covariance matrix for all four variables and...

  • Maintaining a healthy weight is important for women’s health. Some physicians recommend being back to your...

    Maintaining a healthy weight is important for women’s health. Some physicians recommend being back to your pre-pregnancy weight six months after giving birth. Public health officials are interested in whether this is a realistic goal. Do the women in North Carolina weigh more than their pre-pregnancy weight six months postpartum? In other words, is the six months post-pregnancy weight greater than their pre-pregnancy weight? Use a paired samples t-test to compare pst6wght (variable 1) and prewght (variable 2). This uses...

  • Your IT department provided you data on patients that received ER services, their GHHS, and their recovery time. Prepare a report to share with the owners of the facility that will help you make infor...

    Your IT department provided you data on patients that received ER services, their GHHS, and their recovery time. Prepare a report to share with the owners of the facility that will help you make informed decisions about how long you can expect a patients’ recovery time would be based on their GHHS. Based on your findings provide recommendations on your plan moving forward to improve the functioning of your facilities in generating revenue. Prepare a report that addresses each of...

  • LAB8.DAT IS LISTED BELOW 154    -6   279   215   404   391  -166   199  -302  -469   244    &n

    LAB8.DAT IS LISTED BELOW 154    -6   279   215   404   391  -166   199  -302  -469   244     0   -20   405   110   118   359   305    77  -317  -260   387  -471   -10  -332   479   213     0   -29  -440   182  -458  -429    22  -403   318   318   222  -350   160    19   473   149   300   -46   -68   325  -417  -367  -327  -109   331   303  -440  -101    27   -83   157   128  -208   -68  -485   484  -333 -394  -128  -302   -10  -161   452   420  -447   238  -231   -77    48   443   -82   483  -199   201   166    39   198   167  -322  -372   499  -329  -467    61   382   169  -310  -131   -39   482  -344   356   145  -124  -309   -72   -18  -379    90  -274  -115    83  -248  -210   117  -235   324   483   230  -156    84  -392   406   380   318  -239    94  -477   -75  -187  -339 -321   -77  -406    99   -29   196   200   139  -466  -431  -180    31   154   -92   320   218   469    31  -175  -394   111   279   -77  -409  -234  -346  -219   -60    27   -43   375    18   444   138   458  -259   176  -211   172   195  -432  -245  -276   168   344  -156   281   175  -493   102  -113   416  -499   -38   -76   -39   270  -178   285   -29  -464  -324   222   -27 -347  -159   107  -308   238  -257   417  -231   266  -311  -213  -409    76   183    47   -74   144   148   179   136   445  -291   209  -264  -381   107   -50   -41   162   270  -150   162   -84   342   333  -244   113    82    41   370  -235  -182  -381   440   146   -21   139    45   147    44   221    22   494  -281  -394  -390  -436   -95   -52  -134   264   128   272   433 473  -308  -361   196  -406    25    30   361   -15  -107   171   241    20  -152  -350 Goals: Practicing arrays and functions Create a program that will read values from a file called Lab8.dat (posted on Canvas) and store it into an array using a function other than main. The number of values in the file is less than 300 and all the values are whole numbers. The actual number of values stored in the file should be returned to the function call Your program should contain another...

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
ADVERTISEMENT