lemme preface by saying I have read the homework sticky, am not looking for someone to just give me an answer...more then anything I just want to understand this stuff...just am not looking to step on any toes and wanna make sure that's clear, and that I hope someone can help me out a little bit here

here's the deal
I need to "design my program with a function that takes as an argument an integer between 0-99 and returns a string that contains the integer value in english. It shouldn't have 100 different id else statements, I'm supposed to use % and / to "extract the tens and ones digits to construct the english string"

all of this drama is to make a program that outputs the lyrics from "Ninety-nine bottles of beer on the wall"

I'm not looking for someone to write the code for me (although I wouldn't say no hah) what I am looking for though is someone who could mayhaps explain to me wtf all that nonsense means

I have absolutely no idea where to start...I barely understand what a function is

in fact, I don't understand programming at all hah what I have so far is

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

int beer (int number_par);
{


}
int main (void)

{
}

so basically...nothing. Any help would be appreciated cause like I said I don't even know where to THINK about beginning how to approach this

-.- thanks

Dani AI

Generated

— break this into two small, easy pieces: 1) a helper that converts a single number 0–99 into words, and 2) a loop that uses that helper to print each verse with correct grammar (singular/plural, and "no more" for 0). Use small lookup tables for ones, teens, and tens, and keep the conversion function focused and testable.

The heart of the trick is: handle 0–9, 10–19, exact tens (20, 30, ...), and the rest (21, 57, etc.). Use integer division and modulo to split a number into tens and ones, keep the function pure, and test it with edge cases (0, 1, 10, 11, 20, 21, 99). As suggested, reading a beginner C++ tutorial helps for basics like functions and arrays.

Example conversion + lyric loop (complete enough to compile with a modern C++ compiler; remove any Visual Studio-only headers like stdafx.h):

#include <iostream>
#include <string>

std::string numberToWords(int n) {
    static const std::string ones[]  = {"zero","one","two","three","four","five","six","seven","eight","nine"};
    static const std::string teens[] = {"ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
    static const std::string tens[]  = {"","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};

    if (n < 0 || n > 99) return "";
    if (n < 10) return ones[n];
    if (n < 20) return teens[n - 10];
    int t = n / 10;
    int o = n % 10;
    return o ? tens[t] + "-" + ones[o] : tens[t];
}

int main() {
    for (int i = 99; i >= 0; --i) {
        std::string cur = (i == 0) ? "no more" : numberToWords(i);
        std::string bottles = (i == 1) ? "bottle" : "bottles";
        std::cout << cur << " " << bottles << " of beer on the wall,\n";
        std::cout << cur << " " << bottles << " of beer.\n";
        if (i == 0) {
            std::cout << "Go to the store and buy some more, ninety-nine bottles of beer on the wall.\n\n";
        } else {
            int next = i - 1;
            std::string nexts = (next == 0) ? "no more" : numberToWords(next);
            std::string nextB = (next == 1) ? "bottle" : "bottles";
            std::cout << "Take one down and pass it around, " << nexts << " " << nextB << " of beer on the wall.\n\n";
        }
    }
    return 0;
}

Troubleshooting tips: test numberToWords in isolation; check 0/1/10/11/20/21/99; make sure you handle hyphenation (twenty-one) and singular/plural logic. Keep the function small — lookup tables avoid a hundred if statements.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.