The following program involves use of Looping and Decision control structure. De
ID: 3646821 • Letter: T
Question
The following program involves use of Looping and Decision control structure. Declare all appropriate variables.A small business offers motivational seminars to local companies. Table below displays the charges for attending a seminar depending on the number of people attending the seminar.
CHARGES FOR REGISTRANTS OF SEMINARS
No. of people attending charges per person
1-3 $150
4-9 $100
10 or more $90
Using for looping control structure, the program should enter the following data for 3 companies by writing above data to a file Seminar.dat" as 3 separate records.
1. The name of a company using String data type
2. Number of registrants of seminar for that company.
Use the following data for this program.
Name of Co. No. Attending
ABC Films 2
XYZ Computers 6
PQR Distributors 12
The above data will be read in the next program. This is the end of this program.
Explanation / Answer
please rate - thanks
you weren't specific as to what gets written to the file, message me if any problems and I'll make the changes
sample run
input
output file
#include <iostream>
#include <fstream>
using namespace std;
int main()
{ofstream out;
string name;
int n,i,cost;
out.open("Seminar.dat");
for(i=0;i<3;i++)
{cout<<"Enter name of company: ";
getline(cin,name);
cout<<"enter number of attendies: ";
cin>>n;
if(n<=3)
cost=n*150;
else if(n<=9)
cost=n*100;
else
cost=n*90;
out<<name<<" "<<cost<<endl;
cin.ignore(100,' ');
}
out.close();
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.