How to read Json Data from online file?

C++ visual basic. using a loop to read data from a file, calculating average, sum ( total), amount of numbers?

  • he Student CD contains a file named random. txt. This fi le contains a long list of random numbers. Copy the file to your hard dri ve and then write a program that opens the file, reads all the numbers from the fi le, and calculates the fo llowing: A) The number of numbers in the fi le B) The sum of all the numbers in the file (a running total) C) The average of all the numbers in the file The program should display the number of numbers found in the file, the sum of the numbers, and the average of the numbers. Each output for the project should be accompanied with a statement such as: “The average of the data items is ____”. *this is what i have come up with so far. No arrays are being used. just loops, reading data from a file, and calculating. im stuck and i dont no where to go from here. please assist or give examples... #include <iostream> #include <fstream> using namespace std; int main() { ifstream inputFile; //File stream object int sum=0; int number; //to hold a value from the file int count=1; //loop counter, intialized with one inputFile.open("random.txt"); if(!inputFile>>number) cout<<"Error opening the file.\n"; else { while(inputFile >> number) { cout<<number<<endl; } inputFile.close(); } return 0; }

  • Answer:

    Here is a sample program which demonstrates this exact problem: http://programmingnotes.freeweq.com/?p=670

e at Yahoo! Answers Visit the source

Was this solution helpful to you?

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.