Assistance needed, any help is greatly appreciated.

Question:
-------------------------------------------------------------------------------
Write a C++ program that prompts the user with the following options:
Matrix String Quit

(1) If the user selects “M” or “m” then call a user-defined function called float average (void) that will the following:
a. Prompt the user to enter three sets of three numbers (type float) and store the numbers in a 3 x 3 array.
b. Find the transpose of the matrix and print the results in this function.
c. Find the sum of the original matrix and transposed matrix and print the original, transpose, and the sum matrices in this function. Note the output should be in three rows and three columns format with space in between each column as follows:
1 2 3
2 0 9
12 3 7

(2) If the user selects “S” or “s” then call a user-defined function void rev_str (void) that

a. Prompts the user to enter a string and store it into one-dimensional array.
b. Replace the content of the string with the string reversed and save into another
array.
c. Print both the original string and reversed one in this function.

 If the user enters “Q” or “q” then you should terminate the program. If the user enters any other selection it should prompts the user invalid selection and try again.
-------------------------------------------------------------------------------
i know my code is kind of messy, but here is my program underneath the line, I'm still getting errors that my program has some undeclared variables I'm very new to programing I'm in high school and i have missed like the last 3 weeks of school so i did the best i could by using my book and the internet to tackle this assignment my teacher isn't much help the language barrier kind of hinders us from getting help, but fuck this shit is kicking my ass and its due 3/24/14 so I'm trying to get as much help as possible I'm not expecting anyone to do my code for me .. i just need some help so any help is welcome and greatly appreciated..
______________________________________________________________________________________________________________________________________________________________
#include<iostream>


void rev_str(void);
void reverse (char *, char *);
void doubleAverage ();


float main()

{

char input;
cin>>input;
while (input != 'q')
{
cout<<"Matrix String Quit"<<endl;
//cin>>input;

switch(input)
{
case 'S':
case 's':
rev_str();
break;

case 'Q':
case 'q':
cout<<"This program has ended."<<endl;
break;

default:
cout<<"Try reentering another input."<<endl;
input = 'z';
break;
}

}

return (0);
}

void rev_str()
{
const int x=30;
char Input_String[x];
char Output_String[x];



cout<<"Please enter a string:\n";
cin.get();
cin.getline(Input_String, x);
reverse(Input_String, Output_String);
cout<<"The Original string is "<<Input_String<<endl;
cout<<"The reversed string is "<<Output_String<<endl<<endl;
}

void reverse(char *in_str, char *out_str)
{
int y=0;//changed it to int from float
while (*(in_str + y) != '\0')
{
y++;
}
for(y--; y>=0; y--)
{
*out_str++ = *(in_str + y);
*out_str = '\0';
}

}

void doubleAverage()
{

float result=0;



{
float num 8;
float x;

cout << "Please enter the first set of three number:" << endl;
cin >> num0 >> num1 >> num2;

cout << "Please enter second set of three numbers:" << endl;
cin >> num3 >> num4 >> num5;

cout << "Please enter third set of three numbers:" << endl;
cin >> num6 >> num7 >> num8;


for (int i =0; i <9; i++)
t number.
{
if (x < numi)
x + numi;
}

cout << "The greatest number of the three groups is "<<x<< "."
<<endl;

float sum=0;

for (int j=0; j<9; j++)

{
sum = sum + numj;
}

cout << "The sum of the numbers is " << sum << "." << endl;

float temp;
int counter, index;

for (counter = 0; counter < 8; counter++)
{
for (index=0; index < 8 - counter; index++)
if(numindex > numindex + 1)
{
temp = numindex;
numindex = numindex + 1;
numindex + 1 = temp;
}
for (int a =0; a < 9; a++)
rt.
{
cout << numa << "";
}
}
Here is something to get you started, I took out the errors and fixed the reverse string function, also set up the matrix function. You should be able to go from here and finish it. Let me know if you have any questions with some of the changes I made.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include<iostream>

using namespace std;

void rev_str(void);
void reverse (char *, char *);
float average();


int main()
{
    char input;

    do
    {
        cout<<"Matrix String Quit"<<endl;
        cin>>input;

        switch(input)
        {
            case 'S':
            case 's':
                rev_str();
                break;

            case 'Q':
            case 'q':
                cout<<"This program has ended."<<endl;
                break;

            default:
                cout<<"Try reentering another input."<<endl;
                input = 'z';
                break;
        }

    }while (input != 'q');

    return 0;
}

void rev_str()
{
    const int x=30;
    char Input_String[x];
    char Output_String[x];

    cout<<"Please enter a string:\n";
    cin.get();
    cin.getline(Input_String, x);
    reverse(Input_String, Output_String);
    cout<<"The Original string is "<<Input_String<<endl;
    cout<<"The reversed string is "<<Output_String<<endl<<endl;
}

void reverse(char *in_str, char *out_str)
{
    int count = 0, strLength;
    while (in_str[count] != '\0')
        count++;
        
    strLength = count;
    for (int i = 0; i < strLength; i++, count--)
        out_str[count-1] = in_str[i];
}

float average()
{
    float result = 0;
    float num[3][3];
    float sum = 0;
    float temp;
    float x;
    int counter, index;

    cout << "Please enter the first set of three number:" << endl;
    cin >> num[0][0] >> num[0][1] >> num[0][2];

    cout << "Please enter second set of three numbers:" << endl;
    cin >> num[1][0] >> num[1][1] >> num[1][2];

    cout << "Please enter third set of three numbers:" << endl;
    cin >> num[2][0] >> num[2][1] >> num[2][2];


    x = num[0][0];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {	if (x < num[i][j])
                x = num[i][j];
        }
    }

    cout << "The greatest number of the three groups is "<< x << "."<< endl;

    for (int i = 0; i < 3; i++)
        for (int j = 0; j < 3; j++)
            sum += num[i][j];

    cout << "The sum of the numbers is " << sum << "." << endl;


    /*
    for (counter = 0; counter < 8; counter++)
    {
        for (index=0; index < 8 - counter; index++)
        {
            if(numindex > numindex + 1)
            {
                temp = numindex;
                numindex = numindex + 1;
                numindex + 1 = temp;
            }
        }
    }
    */

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
            cout << num[i][j] << " ";
        cout << endl;
    }
}
Last edited on
Topic archived. No new replies allowed.