Question: can someone help me code the bolded part please. #include WebApps.h #include FileApps.h #include #include #include #include #include #include //for isalnum() #include //for file streaming
can someone help me code the bolded part please.
#include "WebApps.h"
#include "FileApps.h"
#include
#include
#include
#include
#include
#include
#include
using namespace std;
WebApps wo;
FileApps fo("survey.txt"); //fo for file object
void build_form();
void save_data_line(string);
void display_result (string);
string prepare_vote(int);
string qs;
void
//string prepare_vote;
int main()
{
const int cnt = wo.get_cnt();
if (cnt != 0) {
cout << "debug with cnt != 0< br>" << endl;
//call function to prepare vote
string data_line = prepare_vote(cnt); //to be implemented,
//explained next
cout << "debug with data_line: " << data_line << "< br>" << endl;
fo.save_data_line(data_line);
}else {
build_form();
}
return 0;
}
////////////functions/////////////
string prepare_vote(int f_cnt) {
//create dynamic array name_value_pairs[] from the wo object
//as done earlier
FIELDS name_value_pairs [cnt];
//parse qs into name_value_pairs[] array from the wo object
//as done earlier
wo.parse(qs, name_value_pairs);
//param the vote field value into variable 'vote' from the wo object
//as done earlier
string vote =wo.param("vote", name_value_pairs, cnt);
cout << "debug with vote: " << vote << "< br>" << endl;
return vote + "| "; //the new line character will put each vote
//on a new line in the file
//ex of a concatenated vote: "y| "
}
void build_form () {
cout << "
"
" <<"
" <<" " <<
" ";
}
void display_result (string f_data_array[])
{
//function flow:
// initialize a dynamic array (vote_tally_array) from function
// create_int_array() which returns a pointer to an array with number of
// elements equal to the number of possible (different) choices of votes:
// For example, Y or N will require a vote_tally_array of 2 elements
//initialize vote_tally_array to 0s in a loop
//In another loop, increment vote_tally_array from f_data_array[]
// vote will need to be extracted from its pipe symbol separator
if vote == "Y" then vote_tally_array[0]++
/else if vote == "N" then vote_tally_array[1]++
//print the results
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
