0

I need help with an assignment. I have to modify the program below to determine the number that was entered the most times in a row and display the output. I can not use files or arrays. I am having trouble with the logic and need some guidance. Thanks.

```
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float num, sum, total_num, total_pos;
float total_neg, total_zero;
char choice;
do
{
//initialize counters
sum=0;
total_num=0;
total_pos=0;
total_neg=0;
total_zero=0;
cout<<"#################################################\n";
cout<<"# #\n";
cout<<"# You will be asked to enter a number. #\n";
cout<<"# You may enter positive, negative or decimal #\n";
cout<<"# values including zero. The program will then #\n";
cout<<"# calculate the sum of the numbers and tabulate #\n";
cout<<"# the types of numbers you entered. #\n";
cout<<"# When you are finished, enter 9999. #\n";
cout<<"# #\n";
cout<<"#################################################\n\n";
cout<<"Please enter a number: ";
cin>>num;
while (num != 9999)
{
if (num > 0)
{
sum = sum + num;
total_num++;
total_pos++;
cout<<"Enter another number. ";
cin>>num;
}
else if (num < 0)
{
sum = sum + num;
total_num++;
total_neg++;
cout<<"Enter another number. ";
cin>>num;
}
else
{
total_num++;
total_zero++;
total_pos++;
cout<<"Enter another number. ";
cin>>num;
}
}
//output of the data entered
cout<<endl<<endl;
cout<<"#################################################\n";
cout<<"# Here is your breakdown: #\n";
cout<<"#################################################\n";
cout<<"# #\n";
cout<<"# Total numbers entered: "<<setw(22)<<total_num<<" #\n";
cout<<"# Total positive numbers entered: "<<setw(13)<<total_pos<<" #\n";
cout<<"# Total negative numbers entered: "<<setw(13)<<total_neg<<" #\n";
cout<<"# Total zeros entered: "<<setw(24)<<total_zero<<" #\n";
cout<<"# The sum of all numbers entered: "<<setw(13)<<sum<<" #\n";
cout<<"# #\n";
cout<<"#################################################\n";
//menu option to continue or end program
cout<<"\nWould you like to enter more numbers? (Y/N) ";
cin>>choice;
}while (choice=='y' || choice=='Y');
return 0;
}
```

Here is some code that I'm trying to use to isolate the counting/comparing process but it's not working out.

```
int main()
{
int num, sum, count, count2, count_total;
int row_count, row_total, num_row;
sum=0;
count=0;
count2=0;
num_row=0;
row_count=0;
cout<<"enter a number. ";
cin>>num;
while (num != 9999)
{
if (num == num)
{
count = count++;
row_count = row_count++;
sum = sum + num;
num_row = num;
cout<<"enter a number. ";
cin>>num;
}
else
{
row_total = row_count;
row_count = 0;
sum = sum + num;
count2 = count2++;
cout<<"enter a number. ";
cin>>num;
}
}
count_total=count+count2;
cout<<"sum = "<<sum<<endl;
cout<<"count = "<<count_total<<endl;
cout<<"row total = "<<row_total<<endl;
system ("pause");
return 0;
}
```