splackavellie69
12-19-2006, 02:29 AM
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
struct dormgames
{
string firstname;
string lastname;
string dorm;
string sport1;
string sport2;
float money;
};
float total1;
float total2;
float total3;
float total4;
float total5;
float total6;
float money1;
float money2;
ifsream infile;
int main()
{
infile.open(“sports.dat”)
while (infile)
{
infile >> dormgames.firstname >> dormgames.lastname >> dormgames.dorm
>> dormgames.sport1 >> dormgames.sport2 >> dormgames.money;
}
return 0;
}
Problem: Your brother has heard that you have learned to write computer programs. Assuming that you can do anything, he has told his friend that you can help him. His friend is the director of inter-dormitory sports here at Howard University. So, last night his friend called you and asked you to write a computer program that will answer the following questions:
1. What is the total amount of money spent on each sport ?
2. What is the total amount of money spent at each of the dormitories?
3. What is the total amount of money spent on each of the sports at each of the
dormitories?
4. What is the total number students participating in each of the sports?
5. What is the total number students participating at each of the dormitories?
6. What is the total number students participating in each of the sports at each of the
dormitories?
Input: Read in a file of 25 records from an external file sports.dat that satisfy the following format:
type of datum meaning range of values
character string student name up to 24 letters
2 characters dormitory {BT, DG, FT, TU, OP, LN}
character string 1st sport played {FOOTBALL, TENNIS, SOCCER,
by this student BASKETBALL}
character string 2nd sport played {FOOTBALL, TENNIS, SOCCER,
by this student BASKETBALL}
Float amount of money $0 – $100.00
spent on this student
(divide by 2 for each
sport if student has
played 2 sports)
To test your program, create an external file named sports.dat and place in it a set of 25 records as described above. Your program should read in this data, store the data in a struct them pass this struct (record) to a function that adds to the appropriate element in a multi-dimensional array (also passed as a parameter). If the student has two sports then split the money in half.
Output: Calculate the total amount in dollars and cents and the total number of students as described above. Provide an output listing that is appropriately formatted and that presents the answers to the questions along with your input data.
Extra Requirements: Use enumerated data type(s). Use a void function to write out your name, course number and title, assignment number, and date, followed by a description of the problem. Use a function somewhere in your calculation that has a struct and a multi-dimensional array as parameters.
i am completely confused i understand the strut and how to use it i just dont kno how to get my program to answer the quwstions needed can someone please help???
#include <fstream>
#include <iomanip>
#include <string>
using namespace std;
struct dormgames
{
string firstname;
string lastname;
string dorm;
string sport1;
string sport2;
float money;
};
float total1;
float total2;
float total3;
float total4;
float total5;
float total6;
float money1;
float money2;
ifsream infile;
int main()
{
infile.open(“sports.dat”)
while (infile)
{
infile >> dormgames.firstname >> dormgames.lastname >> dormgames.dorm
>> dormgames.sport1 >> dormgames.sport2 >> dormgames.money;
}
return 0;
}
Problem: Your brother has heard that you have learned to write computer programs. Assuming that you can do anything, he has told his friend that you can help him. His friend is the director of inter-dormitory sports here at Howard University. So, last night his friend called you and asked you to write a computer program that will answer the following questions:
1. What is the total amount of money spent on each sport ?
2. What is the total amount of money spent at each of the dormitories?
3. What is the total amount of money spent on each of the sports at each of the
dormitories?
4. What is the total number students participating in each of the sports?
5. What is the total number students participating at each of the dormitories?
6. What is the total number students participating in each of the sports at each of the
dormitories?
Input: Read in a file of 25 records from an external file sports.dat that satisfy the following format:
type of datum meaning range of values
character string student name up to 24 letters
2 characters dormitory {BT, DG, FT, TU, OP, LN}
character string 1st sport played {FOOTBALL, TENNIS, SOCCER,
by this student BASKETBALL}
character string 2nd sport played {FOOTBALL, TENNIS, SOCCER,
by this student BASKETBALL}
Float amount of money $0 – $100.00
spent on this student
(divide by 2 for each
sport if student has
played 2 sports)
To test your program, create an external file named sports.dat and place in it a set of 25 records as described above. Your program should read in this data, store the data in a struct them pass this struct (record) to a function that adds to the appropriate element in a multi-dimensional array (also passed as a parameter). If the student has two sports then split the money in half.
Output: Calculate the total amount in dollars and cents and the total number of students as described above. Provide an output listing that is appropriately formatted and that presents the answers to the questions along with your input data.
Extra Requirements: Use enumerated data type(s). Use a void function to write out your name, course number and title, assignment number, and date, followed by a description of the problem. Use a function somewhere in your calculation that has a struct and a multi-dimensional array as parameters.
i am completely confused i understand the strut and how to use it i just dont kno how to get my program to answer the quwstions needed can someone please help???