I do apologize. Now that I posted it in C++ and not C (haha), I was wondering if I could have a little help extending my program from 1-999(which works fine) to -1billion to 1billion. I technically am getting full credit on the project but I was hoping for extra credit to boost my B letter grade for my GPA.
Would this involve more strings each for thousands, millions, and billions?
Sorry if this isnt how it is supposed to look for posting it in code form. I am learning.Code:#include<iostream>
#include<fstream>
#include<stdlib.h>
#include<cmath>
#include <cstdlib>
using namespace std;
string sayones(int o)
{
string sayones[] = {"","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};
return sayones[o];
}
string saytens(int t)
{
string s[] = {"","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"};
return s[t]+" ";
}
string sayhun(int n)
{
return sayones(n)+" hundred ";;
}
string saythree
int main()
{
int num;
cout<<"please input 0-999: ";
cin>>num;
int h, t, o;
h = num/100;
t = (num-100*h)/10;
o = num%10;
if (num<=10||num<20){
string word_form1 = sayones(num-h*100);
cout<< word_form1 <<endl;
}
else {
if (num<=99){
string word_form3 = saytens(t)+ sayones(o);
cout<< word_form3 <<endl;
}
else {
if (num==0) {
cout<<"zero";
}
else {
if (t==1&&num>99){
string word_form2 = sayhun(h)+ sayones(num-h*100);
cout<< word_form2 <<endl; }
else {
string word_form4 = sayhun(h)+ saytens(t)+ sayones(o);
cout << word_form4<<endl;
}
}
}
}
system("PAUSE");
return 0;
}