Thread: Simple Question
View Single Post
Old 03-09-2005, 10:57 AM   #1 (permalink)
maatghandi
Registered User
 
Join Date: Mar 2005
Posts: 2
maatghandi is on a distinguished road
Simple Question

Total newbie here just getting started. I want to output a "bar graph" composed of asteriks (*). The number of asterisks is equal to the value of variable numberOf*.*. I can't find how to do this. Help would be much appreciated!

Code:
#include <iostream>
using namespace std;

int main () {

    int count = 0;
    double score = 0.0;
    int numberOfAs = 0;
    int numberOfBs = 0;
    int numberOfCs = 0;
    int numberOfDs = 0;
    int numberOfFs = 0;

    cout << "Number of A's: " << numberOfAs <<endl;
    cout << "Number of B's: " << numberOfBs <<endl;
    cout << "Number of C's: " << numberOfCs <<endl;
    cout << "Number of D's: " << numberOfDs <<endl;
    cout << "Number of F's: " << numberOfFs <<endl;
    cout << "Enter a score (%) or -1 to end: ";
    cin >> score;

    if (score != -1) {
          // I haven't written the code yet (obviously)
    } else {
         // This is where I want an output of the above numberOf*.* variables in asterik(*) bargraph form (i.e. A's: ***** if the value of numberOfAs = 5)
}
Hope my description isn't confusing,
Maat
maatghandi is offline   Reply With Quote