Thread: Help with creating a Do-While loop

  1. #1
    Registered User
    Join Date
    Apr 2014
    Posts
    1

    Help with creating a Do-While loop

    I need help starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score. Any help is greatly appreciated. Here's what I have so far:

    Code:
    {
    
    //This program calculates a golfers handicap.
    #include <iostream>
    #include <string>
    using namespace std; 
    
    int main()
    {
    
        int score, slope;
        double rating, handicap;
        string name;
    
    
       cout << "This program calculates a golfer's handicap.\n";
    
    //Have the user to input their name, score, slope, and handicap.
        cout << "Enter your name: ";
        cin >> name;
        cout << "Hello " << name << endl;
        cout << "Please enter your score: ";
        cin >> score;
        cout << "Please enter the course slope: ";
        cin >> slope;
        cout << "Please enter the course rating: ";
        cin >> rating;
    
    //Calculate the golfers handicap
        handicap = (score-rating) * 113 / slope ;
        cout << "Your handicap is " << handicap << endl;
    
    
    return 0;
    
    }
    
    

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    You seem to have an extra opening brace at the beginning of the file. Besides this, you don't seem to have tried writing your loop yet.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help creating Boxes (grid) using for loop
    By ddurr in forum C Programming
    Replies: 0
    Last Post: 11-21-2013, 04:42 AM
  2. Creating pthreads in for loop
    By 0624167 in forum Linux Programming
    Replies: 4
    Last Post: 02-13-2008, 12:10 PM
  3. Help with dynamically creating controls in a loop
    By earth_angel in forum Windows Programming
    Replies: 1
    Last Post: 06-29-2005, 07:31 PM
  4. Creating a Loop (PLEASE HELP!)
    By ChaosTony in forum C++ Programming
    Replies: 15
    Last Post: 09-28-2004, 08:34 PM
  5. creating new objects in loop
    By Joe_Gibbs in forum C++ Programming
    Replies: 3
    Last Post: 04-10-2004, 09:04 AM