how to make a graf

Hi, a just started learning C++ from e-book Jumping into C++.
from: Alex Allain.
At the end of each capitol there are practice problems. and i dont know how to solve the last part of one of these problems.

chapter 5, Practice problem 7.:
Write a program that provides the option of tallying up the results of a poll with 3 possible
values. The first input to the program is the poll question; the next three inputs are the possible
answers. The first answer is indicated by 1, the second by 2, the third by 3. The answers are
tallied until a 0 is entered. The program should then show the results of the poll—try making a
bar graph that shows the results properly scaled to fit on your screen no matter how many
results were entered.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <string>
#include <iostream>

using namespace std;

int main ()
{
  string choice,Q,answer1,answer2,answer3;
  float one=0,two=0,three=0;
  
  cout << "\t" << "Enter your Question: " << "\n";
  getline (cin,Q,'\n');
  cout << "\t" << "Enter your first answer: " << "\n";
  getline (cin,answer1,'\n');
  cout << "\t" << "Enter your second answer: " << "\n";
  getline (cin,answer2,'\n');
  cout << "\t" << "Enter your third answer: " << "\n";
  getline (cin,answer3,'\n');
  
  do
  {    
    cout << "\n" << Q << "\n""\n";
    cout << "1 - " << answer1 << "\n";
    cout << "2 - " << answer2 << "\n";
    cout << "3 - " << answer3 << "\n";
    cout << "0 - Press to exit" << "\n";
    getline(cin,choice,'\n');
    if(choice == "1"){
      one++;
    }
    else if(choice == "2"){
     two++;
    }
    else if(choice == "3"){
     three++;
    }
    else if(choice == "0"){
    }
    else
    {
      cout << "\t" "\t"<< "nevybrali ste platnu hodnotu!!!" << "\n""\n";
    }
  } while (choice != "0");{
    cout << "\n";
    cout << "  1: " << one << " answers" << " - " << one*100/(one+two+three) << "%" << "\t""\t";
    cout << "  2: " << two << " answers"<<" - " << two*100/(one+two+three) << "%" << "\t""\t";
    cout << "  3: " << three << " answers" <<" - " << three*100/(one+two+three) << "%" << "\t""\t""\n""\n";
  }
}


dont know how to create a bar graf.

thx for help.
Last edited on
Topic archived. No new replies allowed.