473,395 Members | 1,584 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

help writing this program!

i have this program that i am almost done with, i am one part away from being done.

the last part is putting the results together;
here is the results that i need to put in code. do u have any ideas on how to write code to this using functions.please any thing will help

CONFERENCE OVERALL
RANK TEAM W-L % WINS MARGIN W-L % WINS MARGIN
1 KSU 3-1 .750 +10.50 8-1 .889 +13.56
1 CAP 3-1 .750 +11.75 7-2 .778 +13.67
1 ONU 3-1 .750 +15.25 7-2 .778 +17.78
1 OTT 3-1 .750 +14.00 5-4 .556 +7.56
1 WILM 3-1 .750 +7.25 7-2 .778 +10.00
6 MUC 2-2 .500 -6.25 4-4 .500 -0.50
7 MUSK 1-2 .333 -12.00 5-3 .625 +2.63
8 HEID 1-3 .250 -4.00 3-4 .429 +1.57
9 JCU 0-3 .000 -13.00 2-5 .286 -3.00
9 MAR 0-4 .000 -29.75 2-7 .222 -10.89



here is the code for what i have for my program so far.

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <string>
  6. #include <fstream>
  7.  
  8. using namespace std;
  9.  
  10. struct basketballStat
  11. {
  12.     string schoolName;
  13.     int numberWins;
  14.     int numberLosses;
  15.     int numberPointsTheTeamScored;
  16.     int numberPointsTheTeamScoredAgainst;
  17.     int teamOverallWins;
  18.     int teamOverallLosses;
  19.     int numberPointsTheTeamScoredInAll;
  20.     int numberPointsTheTeamScoredInAllAgainst;
  21. };
  22.  
  23. struct basketballStatUpdate
  24. {
  25.     string date;
  26.     string nameOfHomeTeam;
  27.     int homeTeamsPointTotal;
  28.     string nameOfVisitTeam;
  29.     int VisitingTeamsPointTotal;
  30. };
  31.  
  32. void FormerStats (ifstream&, basketballStat&);
  33. void Updates (ifstream&, basketballStatUpdate&);
  34. void DoUpdate(basketballStat[], basketballStatUpdate&);
  35. void UpdatedStats(ostream&, basketballStat[]);
  36.  
  37.  
  38.  
  39. int main ()
  40. {
  41.     basketballStat formerStats[10];
  42.  
  43.     ifstream inFile1;
  44.     inFile1.open ("G:\\formerstats.txt");
  45.     ifstream inFile2;
  46.     inFile2.open("G:\\updates.txt");
  47.     ofstream outFile1;
  48.     outFile1.open ("G:\\updatedStats.txt");
  49.     ofstream outFile2;
  50.     outFile2.open ("G:\\standings.txt");
  51.  
  52.     for (int k=0; k<10; k++)
  53.     {
  54.         FormerStats (inFile1, formerStats[k]);
  55.     }
  56.  
  57.     while (!inFile2.eof())
  58.     {
  59.         basketballStatUpdate update;
  60.         Updates (inFile2, update);
  61.         DoUpdate(formerStats, update);
  62.     }
  63.  
  64.     inFile1.close();
  65.     inFile2.close();
  66.  
  67.     UpdatedStats(outFile1, formerStats);
  68.  
  69.     outFile2<<setw(30)<<"CONFERENCE"<<setw(10)<<"OVERALL"<<endl;
  70.     outFile2<<"RANK"<<setw(6)<<"TEAM"<<setw(7)<<"W-L"<<setw(9)<<"% WINS"<<setw(11)<<"MARGIN"<<setw(8)<<"W-L"<<setw(9)<<"% WINS"<<setw(11)<< "MARGIN"<<endl;
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78.     return 0;
  79. }
  80.  
  81. void FormerStats (ifstream &inFile1, basketballStat &myStat)  //this void function reads in the data from formerstats
  82. //within the basketballStat struct.
  83. {
  84.  
  85.     inFile1 >> myStat.schoolName;
  86.     inFile1 >> myStat.numberWins;
  87.     inFile1 >> myStat.numberLosses;
  88.     inFile1 >> myStat.numberPointsTheTeamScored;
  89.     inFile1 >>myStat.numberPointsTheTeamScoredAgainst;
  90.     inFile1 >> myStat.teamOverallWins;
  91.     inFile1 >> myStat.teamOverallLosses;
  92.     inFile1 >> myStat.numberPointsTheTeamScoredInAll;
  93.     inFile1 >> myStat.numberPointsTheTeamScoredInAllAgainst;
  94. }
  95.  
  96. void Updates (ifstream& inFile2, basketballStatUpdate &update) //this void function reads in the data from updates.txt and
  97. //struct called basketballStat update is being used to read in the data.
  98. {
  99.  
  100.     inFile2 >> update.date;
  101.     inFile2 >> update.nameOfHomeTeam;
  102.     inFile2 >> update.homeTeamsPointTotal;
  103.     inFile2 >> update.nameOfVisitTeam;
  104.     inFile2 >> update.VisitingTeamsPointTotal;
  105. }
  106.  
  107. void DoUpdate(basketballStat myStat[], basketballStatUpdate &update) // this function updates the stats of the conference games
  108. // and calculates each data for each game and updates it into a recent and update form of the stats in the conference games. 
  109. {
  110.     bool homeOfTheConfTeam = false, visitConfTeam = false;
  111.     int homeTeamIndex, visitTeamIndex;
  112.     for (int j=0; j<10; j++)
  113.     {
  114.         if (myStat[j].schoolName==update.nameOfHomeTeam) 
  115.         {
  116.             homeOfTheConfTeam = true;
  117.             homeTeamIndex = j;
  118.         } else if (myStat[j].schoolName==update.nameOfVisitTeam) 
  119.         {
  120.             visitConfTeam = true;
  121.             visitTeamIndex = j;
  122.         }
  123.         if (homeOfTheConfTeam&&visitConfTeam) break;
  124.     }
  125.  
  126.     bool homeWin = (update.homeTeamsPointTotal > update.VisitingTeamsPointTotal);
  127.  
  128.     if (homeOfTheConfTeam) 
  129.     {
  130.         myStat[homeTeamIndex].numberPointsTheTeamScoredInAll += update.homeTeamsPointTotal;
  131.         myStat[homeTeamIndex].numberPointsTheTeamScoredInAllAgainst += update.VisitingTeamsPointTotal;
  132.         if (homeWin)
  133.             myStat[homeTeamIndex].teamOverallWins++;
  134.         else
  135.             myStat[homeTeamIndex].teamOverallLosses++;
  136.     }
  137.     if (visitConfTeam) 
  138.     {
  139.         myStat[visitTeamIndex].numberPointsTheTeamScoredInAll += update.VisitingTeamsPointTotal;
  140.         myStat[visitTeamIndex].numberPointsTheTeamScoredInAllAgainst += update.homeTeamsPointTotal;
  141.         if (!homeWin)
  142.             myStat[visitTeamIndex].teamOverallWins++;
  143.         else
  144.             myStat[visitTeamIndex].teamOverallLosses++;
  145.     }
  146.     if (homeOfTheConfTeam&&visitConfTeam) 
  147.     {
  148.         myStat[homeTeamIndex].numberPointsTheTeamScored += update.homeTeamsPointTotal;
  149.         myStat[homeTeamIndex].numberPointsTheTeamScoredAgainst += update.VisitingTeamsPointTotal;
  150.         myStat[visitTeamIndex].numberPointsTheTeamScored += update.VisitingTeamsPointTotal;
  151.         myStat[visitTeamIndex].numberPointsTheTeamScoredAgainst += update.homeTeamsPointTotal;
  152.         if (homeWin) 
  153.         {
  154.             myStat[homeTeamIndex].numberWins++;
  155.             myStat[visitTeamIndex].numberLosses++;
  156.         } else
  157.         {
  158.             myStat[visitTeamIndex].numberWins++;
  159.             myStat[homeTeamIndex].numberLosses++;
  160.         }
  161.     }
  162. }
  163.  
  164. void UpdatedStats(ostream &outFile1, basketballStat myStats[])// this  function stores the calculations from the upbove function
  165. // and uses a set of arrays to write the updated stats data in the outfile1.
  166. {
  167.     for (int m=0; m<10; m++) 
  168.     {
  169.         outFile1 << myStats[m].schoolName << " ";
  170.         outFile1 << myStats[m].numberWins << " ";
  171.         outFile1 << myStats[m].numberLosses << " ";
  172.         outFile1 << myStats[m].numberPointsTheTeamScored << " ";
  173.         outFile1 << myStats[m].numberPointsTheTeamScoredAgainst << " ";
  174.         outFile1 << myStats[m].teamOverallWins << " ";
  175.         outFile1 << myStats[m].teamOverallLosses << " ";
  176.         outFile1 << myStats[m].numberPointsTheTeamScoredInAll << " ";
  177.         outFile1 << myStats[m].numberPointsTheTeamScoredInAllAgainst << " " << endl;
  178.     }
  179.  
  180. }
  181.  
Dec 7 '08 #1
4 1689
newb16
687 512MB
Aren't they already put together?
Dec 7 '08 #2
no its not put together, that data from the chart has to be displayed into another outfile. using functions and thats what im having trouble with.
i need help with the code
Dec 7 '08 #3
sicarie
4,677 Expert Mod 4TB
charmeda103-

Please do not double-post your questions. I have deleted your other thread on this question.

If you have any more information, post it in this thread only.

Thanks,

sicarie
Dec 8 '08 #4
newb16
687 512MB
@charmeda103
Not that I'm going to write the code for you, but I still can't get what your program is expected to do. Do you? I see some data ( input? expected output? ) and some code that I definitely am not going to compile and feed with provided data.
Dec 8 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
10
by: atlanta | last post by:
this is a simple C++ program to write. "Write a complete and functioning structured program that successfully compiles on Visual C++ 6, that uses two-dimensional array (5x5) that stores...
27
by: SK | last post by:
Hi I am trying to teach myself how to program in C. I am a physician hoping to be able to help restructure my office. Anyhow, I amhoping that the porblem I am having is simple to those much more...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
12
by: asif929 | last post by:
I am trying to write a program which creates four triangles. The program begins with prompting a user " Enter the size of triangles", number from 1 to N is the size of four triangles For Example if...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
12
by: adamurbas | last post by:
ya so im pretty much a newb to this whole python thing... its pretty cool but i just started today and im already having trouble. i started to use a tutorial that i found somewhere and i followed...
1
by: siva041986 | last post by:
Hi there, This is Siva. I need some help in writing a program for Unix. I need to write a program using Semaphores and avoid deadlocks and starvation. If you think you can help me please let me...
5
by: dm3281 | last post by:
I'm really starting to hate writing services -- or trying to, anyway. Why do I need to rename my project to the service name? Why do I need to set the "ServiceName" property to my service name?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.