#include <iostream>
#include <string>
#include <fstream>
#include<iomanip>
int main()
{
std::string line;
std::ifstream readyPlayerOne("sales.txt");
std::string firstName{};
if (!readyPlayerOne)
{
std::cout << "\n File " << std::quoted("sales.txt") << " did not open\n";
return 1;
}
constint MINIMUM = 0,
hundred = 100;
int totalSales{};
char symbol = '*';
while (readyPlayerOne >> firstName >> totalSales)
{
int MAXIMUM = totalSales / hundred;
for (int i = MINIMUM; i < MAXIMUM; i++)
std::cout << std::right << std::setw(10) << firstName << ": " << symbol << endl;
}
readyPlayerOne.close(); // <--- Not required as the stream will close when the function looses scope. OK if you leave it.
return 0;
}
I do differ with whitenite1. You should learn to not use usingnamespace std; as a global variable because of the problems it causes. Better to learn what is in the standard name space and to quilify, (std::), what you need. You have already demonstrated that you can and does not cause any problems to use usingnamespace std; along with std::string line;, for example.
It is always a good practice to initial your variables when they are defined. Especially numeric variables.