write both program in C++ The manager of a football stadium wants you to write a
ID: 3781461 • Letter: W
Question
write both program in C++
The manager of a football stadium wants you to write a program that calculates the total ticket sales after each game. There are four types of tickets-box, sideline, premium, and general admission. After each game, data is stored in a file in the following form: ticket Price number Of Tickets Sold Sample data are shown below: The first line indicates that the ticket price is $250 and that 5750 tickets were sold at that price. Output the number of tickets sold and the total sale amount. Format your output with two decimal places. In a right triangle, the square of the length of one side is equal to the sum of the squares of the lengths of the other two sides. Write a program that prompts the user to enter the lengths of three sides of a triangle and then outputs a message indicating whether the triangle is a right triangle.Explanation / Answer
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
ifstream myfile ("????");
if (myfile.is_open())
{
while ( inFile >> ticketPrice >> ticketSold )
{
cout<<"250"<<setw(8)<<box<<endl;
cout<<"100"<<setw(9)<<sideline<<endl;
cout<<"50"<<setw(10)<<premium<<endl;
cout<<"25"<<setw(10)<<genadmission<<endl;
cout << "Number of tickets sold : " << ticketSold << endl;
cout << "Total sale ammount : " << ticketPrice * ticketSold << endl;
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
}
b)
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a,b,c;
cout << "Enter the length of three sides. " << endl;
cin >> a >> b >>c;
if(pow(c,2)-pow(b,2)-pow(a,2) == 0)
cout << "It is a right triangle " << endl;
else if (pow(b,2)-pow(a,2)+pow(c,2) == 0 )
cout << "It's a right triangle" << endl;
else if (pow(c,2) -pow(b,2)+pow(a,2)==0 )
cout << "It's a right triangle" << endl;
else
cout << "It is not a right triangle. " << endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.