Question: All the code for this program- #include splashkit.h #include using namespace std; int convert_to_integer( string prompt) { int result; result = convert_to_integer(prompt); return result; }
All the code for this program-





#include "splashkit.h"
#include
using namespace std;
int convert_to_integer( string prompt)
{
int result;
result = convert_to_integer(prompt);
return result;
}
string read_string(string prompt)
{
string result;
write(prompt);
result = read_line();
return result;
}
int read_integer(string prompt)
{
string line;
line = read_string(prompt);
return convert_to_integer(line);
}
void output_crazy_age(int age)
{
write(to_string(age) + "is a");
int i = 0;
while ( i
{
write("crazy");
// i = i + 1;
i++;
}
write_line(" age ");
}
int user_menu()
{
write_line("1. What is your name");
write_line("2.What is your name ");
write_line("3. Guess that number");
write_line("4. Quit");
}
void test_user_name()
{
string name;
string line;
name = read_string (" What is your name: ");
write_line("Hello "+ name);
if (name == "Sir Kap")
{
write_line(" Bravely bold Sir Kap...");
write_line(" He was not afraid to save innocent people...");
}
else
{
if (name == "Benson")
{
write_line(" Hello My King");
}
}
}
void test_user_age()
{
int age;
string line;
line = read_string (" What is your age: ");
age = convert_to_integer(line);
write("Age: ");
write_line(age);
if ( age == 35 or age == 80 )
{
write_line("Intersing Age!");
}
else if ( age 100 )
{
write_line("Are you serious?");
}
else if ( age > 5 and age
{
output_crazy_age(age);
}
else
{
write_line("Great you are " + to_string(age));
}
}
void play_guess_that_number()
{
string line;
int guess;
int target;
target = rnd(100) + 1;
write_line("I`m thinking of a number between 1 and 100");
while ( guess != target)
{
write("Enter guess: ");
line = read_line();
guess = convert_to_integer(line);
if (guess
{
write_line("Sorry, my number is greatter than " + to_string(guess));
}
else if (guess > target )
{
write_line("No, my number is less than " + to_string(guess));
}
}
write_line("WoW... you got it. My number was " + to_string(target));
}
int main()
{
string name;
int option;
do
{
option = user_menu();
option = read_integer(" Choose option: ");
switch(option)
{
case 1:
test_user_name();
break;
case 2:
test_user_age();
break;
case 3:
play_guess_that_number();
break;
case 4:
write_line("See you later...");
break;
default:
write_line(" Please enter an option from the menu");
}
}while(option != 3);
return 0;
}
Question1) Fix the Code
Problem - No declaration, trying to redefine an existing function - they all contribute to program errors
Comment on the program regarding this issue-
more than one instance of overloaded function "convert_to_integer" matches the argument list
1 include "splashkit.h #1nclude
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
