HELP ME FIX MY CODE #include using namespace std; void breakapart(int n, int &a, int &b, int &c); void writeNum(int digit); void writeSingle(int n); void writeTens(int tensD, int onesD); int main() { int num, first, second, third; cout<<"Input a 9 digit number "<>num; // Break the number into three three-digit numbers breakapart(num,first,second,third); writeNum(first); // If number is above or equal to one million, print name million if(num>=1000000) { cout<<"million "; } writeNum(second); // If number second in break not equal to 0, print name thousand if(second!=0) { cout<<"thousand "; } writeNum(third); return 0; } //Break the number into three three-digit numbers void breakapart(int n, int &a, int &b, int &c) { c = n%1000; n = n/1000; b = n%1000; n = n/1000; a = n%1000; n = n/1000; } // Read number one digit void writeSingle(int digit) { switch(digit) { case 1: cout<<"one "; break; case 2: cout<<"two "; break; case 3: cout<<"three "; break; case 4: cout<<"four "; break; case 5: cout<<"five "; break; case 6: cout<<"six "; break; case 7: cout<<"seven "; break; case 8: cout<<"eight "; break; case 9: cout<<"nine "; break; } } // Read number ten digit void writeTens(int tensD, int onesD) { switch(tensD) { case 1: switch(onesD) { case 0: cout<<"ten "; break; case 1: cout<<"eleven "; break; case 2: cout<<"twelve "; break; case 3: cout<<"thirteen "; break; case 4: cout<<"fourteen "; break; case 5: cout<<"fifteen "; break; case 6: cout<<"sixteen "; break; case 7: cout<<"seventeen "; break; case 8: cout<<"eighteen "; break; case 9: cout<<"nineteen "; break; } break; case 2: cout<<"twenty "; break; case 3: cout<<"thirty "; break; case 4: cout<<"forty "; break; case 5: cout<<"fifty "; break; case 6: cout<<"sixty "; break; case 7: cout<<"seventy "; break; case 8: cout<<"eighty "; break; case 9: cout<<"ninty "; break; } } void writeNum(int n) { // break number into single digit int one, two, three; three = n%10; n = n/10; two = n%10; n = n/10; one = n; writeSingle(one); // If number one above equal to 0, print name hundred if(one > 0) { cout<<"hundred "; } writeTens(two, three); writeSingle(one); }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

HELP ME FIX MY CODE

#include <iostream>

using namespace std;

void breakapart(int n, int &a, int &b, int &c);
void writeNum(int digit);
void writeSingle(int n);
void writeTens(int tensD, int onesD);

int main()
{
int num, first, second, third;
cout<<"Input a 9 digit number "<<endl;
cin>>num;
// Break the number into three three-digit numbers
breakapart(num,first,second,third);
writeNum(first);
// If number is above or equal to one million, print name million
if(num>=1000000)
{
cout<<"million ";
}
writeNum(second);

// If number second in break not equal to 0, print name thousand
if(second!=0)
{
cout<<"thousand ";
}
writeNum(third);
return 0;
}

//Break the number into three three-digit numbers
void breakapart(int n, int &a, int &b, int &c)
{
c = n%1000;
n = n/1000;

b = n%1000;
n = n/1000;

a = n%1000;
n = n/1000;
}

// Read number one digit
void writeSingle(int digit)
{
switch(digit)
{
case 1: cout<<"one "; break;
case 2: cout<<"two "; break;
case 3: cout<<"three "; break;
case 4: cout<<"four "; break;
case 5: cout<<"five "; break;
case 6: cout<<"six "; break;
case 7: cout<<"seven "; break;
case 8: cout<<"eight "; break;
case 9: cout<<"nine "; break;
}
}

// Read number ten digit
void writeTens(int tensD, int onesD)
{
switch(tensD)
{
case 1:
switch(onesD)
{
case 0: cout<<"ten "; break;
case 1: cout<<"eleven "; break;
case 2: cout<<"twelve "; break;
case 3: cout<<"thirteen "; break;
case 4: cout<<"fourteen "; break;
case 5: cout<<"fifteen "; break;
case 6: cout<<"sixteen "; break;
case 7: cout<<"seventeen "; break;
case 8: cout<<"eighteen "; break;
case 9: cout<<"nineteen "; break;
}
break;
case 2: cout<<"twenty "; break;
case 3: cout<<"thirty "; break;
case 4: cout<<"forty "; break;
case 5: cout<<"fifty "; break;
case 6: cout<<"sixty "; break;
case 7: cout<<"seventy "; break;
case 8: cout<<"eighty "; break;
case 9: cout<<"ninty "; break;
}
}

void writeNum(int n)
{
// break number into single digit
int one, two, three;

three = n%10;
n = n/10;

two = n%10;
n = n/10;

one = n;

writeSingle(one);
// If number one above equal to 0, print name hundred
if(one > 0)
{
cout<<"hundred ";
}
writeTens(two, three);
writeSingle(one);

}

case 9: cout<<"nineteen "; break;
break
case 2: cout<<"twenty "; break;
case 3: cout<<"thirty "; break;
case 4: cout<<"fourty "; break;
case 5: cout<<"sfty ": break;
case 6: cout<<"aixty ", break
case 7: cout<<"seventy ": break;
case 8: cout<<-eignty"; Dreax;
case 9: cout<<"ninty ", break
forty
void writeNum (int n)
// break number into single digit
int one, two, three:
three - n10;
n - n/10;
two - n10;
n - n/10;
one- ni
writesingle (ane);
// If number one above equal to o, print name hundred
if (one > O)
cout<<"hundred ";
writeTens (two, three);
writesingle (three)
Not if n is in the
teens.
Transcribed Image Text:case 9: cout<<"nineteen "; break; break case 2: cout<<"twenty "; break; case 3: cout<<"thirty "; break; case 4: cout<<"fourty "; break; case 5: cout<<"sfty ": break; case 6: cout<<"aixty ", break case 7: cout<<"seventy ": break; case 8: cout<<-eignty"; Dreax; case 9: cout<<"ninty ", break forty void writeNum (int n) // break number into single digit int one, two, three: three - n10; n - n/10; two - n10; n - n/10; one- ni writesingle (ane); // If number one above equal to o, print name hundred if (one > O) cout<<"hundred "; writeTens (two, three); writesingle (three) Not if n is in the teens.
include <iostream
using namespace std;
void breakapart (int n, int sa, int sb, int sc) ;
void writeNum (int digit);
void writesingle (int n);
void writeTens (int tensD, int onesD);
int main()
int num, first, second, thirdi
cout<<"Input a9 digit number "<<endl;
cin>>num,
// Break the number into three three-digit numbers
breakapart (num, first, second, third);
writeNum (firat)
// If number is above or equal to one million, print name million
Doesn't work yet.
Try 112.
if (num>-1000000)
cout<<"mi1lion "
writeNum (second):
// If number second in break not equal to 0, print name thousand
if (second!-0)
cout <<"thousand "
writeNum (third)
return 0;
//Break the number into three three-digit numbers
void breakapart (int n, int sa, int sb, int sc)
C - ni1000,
n - n/1000,
b - ni1000;
n - n/1000,
a - n1000,
n - n/1000;
// Read nLumber one digit
void writesingle (int digit)
switch (digit)
case 1: cout<<"one "; break;
case 2: cout<<"two ", break,
case 3: conts"thres ": break
Transcribed Image Text:include <iostream using namespace std; void breakapart (int n, int sa, int sb, int sc) ; void writeNum (int digit); void writesingle (int n); void writeTens (int tensD, int onesD); int main() int num, first, second, thirdi cout<<"Input a9 digit number "<<endl; cin>>num, // Break the number into three three-digit numbers breakapart (num, first, second, third); writeNum (firat) // If number is above or equal to one million, print name million Doesn't work yet. Try 112. if (num>-1000000) cout<<"mi1lion " writeNum (second): // If number second in break not equal to 0, print name thousand if (second!-0) cout <<"thousand " writeNum (third) return 0; //Break the number into three three-digit numbers void breakapart (int n, int sa, int sb, int sc) C - ni1000, n - n/1000, b - ni1000; n - n/1000, a - n1000, n - n/1000; // Read nLumber one digit void writesingle (int digit) switch (digit) case 1: cout<<"one "; break; case 2: cout<<"two ", break, case 3: conts"thres ": break
Expert Solution
Step 1

EXPLANATION:

  • Following is the corrected code for representing the required result:

#include <iostream>
using namespace std;
void breakapart(int n, int &a, int &b, int &c);
void writeNum(int digit);
void writeSingle(int n);
void writeTens(int tensD, int onesD);
int main()
{
    int num, first, second, third;
    cout<<"Input a 9 digit number "<<endl;
    cin>>num;
    // Break the number into three three-digit numbers
    breakapart(num,first,second,third);
    writeNum(first);
    // If number is above or equal to one million, print name million
    if(num>=1000000)
    {
        cout<<"million ";
    }
    writeNum(second);
    // If number second in break not equal to 0, print name thousand
    if(second!=0)
    {
        cout<<"thousand ";
    }
    writeNum(third);
    return 0;
}
//Break the number into three three-digit numbers
void breakapart(int n, int &a, int &b, int &c)
{
    c = n%1000;
    n = n/1000;
    b = n%1000;
    n = n/1000;
    a = n%1000;
    n = n/1000;
}
// Read number one digit
void writeSingle(int digit)
{
    switch(digit)
    {
        case 1: cout<<"one "; break;
        case 2: cout<<"two "; break;
        case 3: cout<<"three "; break;
        case 4: cout<<"four "; break;
        case 5: cout<<"five "; break;
        case 6: cout<<"six "; break;
        case 7: cout<<"seven "; break;
        case 8: cout<<"eight "; break;
        case 9: cout<<"nine "; break;
    }
}
// Read number ten digit
void writeTens(int tensD, int onesD)
{
    switch(tensD)
    {
        case 1:
        switch(onesD)
        {
            case 0: cout<<"ten "; break;
            case 1: cout<<"eleven "; break;
            case 2: cout<<"twelve "; break;
            case 3: cout<<"thirteen "; break;
            case 4: cout<<"fourteen "; break;
            case 5: cout<<"fifteen "; break;
            case 6: cout<<"sixteen "; break;
            case 7: cout<<"seventeen "; break;
            case 8: cout<<"eighteen "; break;
            case 9: cout<<"nineteen "; break;
        }
        break;
        case 2: cout<<"twenty "; break;
        case 3: cout<<"thirty "; break;
        case 4: cout<<"forty "; break;
        case 5: cout<<"fifty "; break;
        case 6: cout<<"sixty "; break;
        case 7: cout<<"seventy "; break;
        case 8: cout<<"eighty "; break;
        case 9: cout<<"ninty "; break;
    }
}
void writeNum(int n)
{
    // break number into single digit
    int one, two, three;
    three = n%10;
    n = n/10;
    two = n%10;
    n = n/10;
    one = n;
    writeSingle(one);
    // If number one above equal to 0, print name hundred
    if(one > 0)
    {
        cout<<"hundred ";
    }
    writeTens(two, three);
}

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education