#c++ question

37 messages · Page 1 of 1 (latest)

fiery swift
#

i have a project that needs to be done but i am having trouble it is a c++ program

#

ok i created a chat here

#

Ninety-Nine Bottles of Beer on the Wall

Write a program that outputs the lyrics for the song “Ninety-Nine Bottles
of Beer on the Wall.” Your program should print the number of bottles in
English, not as a number.

For example:
Ninety-nine bottles of beer on the wall,
Ninety-nine bottles of beer,
Take one down, pass it around,
Ninety-eight bottles of beer on the wall.

One bottle of beer on the wall,
One bottle of beer,
Take one down, pass it around,
Zero bottles of beer on the wall.

Design your program with a function that takes as an argument an integer between 0 and 99 and returns a string that contains the integer value in English. Your function should not have 100 different if-else statements! Instead, use % and / to extract the tens and ones digits to construct the English string. You may need to test specifically for values such as 0, 10–19, etc.

Requirements:
DO NOT COUT the ENTIRE LYRICS as the program.
You must use at least 1 array.
You must write at least 1 other function.
Please space out each verse.

Bonus (+1 each):
Write and use a function that will return a string with the first letter of a string parameter capitalized.
Keep the main function in 5 lines.
Write the lyrics to Nine-Hundred Ninety-Nine Bottles of Beers on the Wall (+3 pts)

heavy quarry
#

on it

fiery swift
#

thank you thank you

heavy quarry
#

hold on ive been trying to solve an error with my codeblocks, it says compiler setup invalid

#

ill just do it in another ide

chilly falcon
# heavy quarry on it

@fiery swift @heavy quarry This server is not for getting people to do work for you.

#

It's much better if you provide what you're got and what the problem seems to be. From there we can help guide you towards fixing it yourself.

heavy quarry
chilly falcon
#

!rule academics

cunning harnessBOT
#
Academic Honesty

You may ask for help with homework but asking others to help on tests/quizzes or to do your coursework for you is not allowed.

heavy quarry
#

ahh okay okay

chilly falcon
heavy quarry
#

i wont give away the solution then

#

i mean ill still solve it for myself

#

but not give it away

chilly falcon
#

Also there's the academic dishonesty thing where it's not their work and they might get in trouble (or they just don't listen to the explanation lol)

fiery swift
#

you can just explain a little bit

#

ill do the rest myself

#

based off of the code i have

#

am i on the right track?

sterile basin
#

what code do you have so far?

#

this is something you'll want to break down and tackle in parts. For example the problem says to make a function that turns a number into english, so thats a good section to start with. The hint is to extract the tens and ones place, so start by writing code to extract those and think about how you would use those to write numbers in english.

fiery swift
#

#include <iostream>
using namespace std;

void numnum(string tens[]){
for (int i=7; i>=0; i--){
cout<<tens[i]<<endl;
}
}

void numnum2(string ones[]){
for (int i=10; i<=0; i--){
cout<<ones[i]<<endl;
}
}

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

cout<< ""<<"bottles of beer on the wall"<<" "<<"bottles of beer, take one down, pass it around"<<" "<<"bottles of beer on the wall";  
}

}

#

this s what i have so far

#

but i dont know if im even on the right track

fiery swift
sterile basin
#

you are on the right track, but you will want to confine your logic for converting numbers into english to the function which does it

fiery swift
#

right right

sterile basin
#

and you should create a function with a descriptive name, a name which describes what it does - numnum is not very descriptive

#

place the arrays in that function since they will be used in that function to make the english

fiery swift
#

alright

#

thanks for the help

sterile basin
#

you shouldnt need a loop to construct english from a given number

#

simply pick the things out of the array that you need, and write code to catch any exceptions to the rule

fiery swift
#

ok sure