trouble with a while loop

Write your question here.
Write a menu driven program that uses Do While loops to evaluate the following polynomials. Display the results in a table. Include column headings. The user should select from the menu the polynomial they want to evaluate and also enter the starting value for X, the stopping value for X, and the increment value.
Y=X3-2X+10
Y=X4+3X2-15
Y=X2-10
Use the following sample data to test your program.
RUN 1: Select the first polynomial and let X range from –7 to 7 in increments of 0.5.
RUN 2: Select the second polynomial and let X range from 0 to 50 in increments of 5.
RUN 3: Select the third polynomial and let X range from 5 to 10 in increments of 0.25.
RUN 4: Make an invalid select from the menu.




The problem is that this program is seriously wrong somewhere
it's runing wrong steps and it doesn't end when it should end
A lot of trouble
Write something trying to help debug but i just cant.
is that =="string" wrong?
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
#define _USE_MATH_DEFINES
#include<iostream>
#include <math.h>
#include<string>
using namespace std;
int main()
{//variables defined here

char exit_variable;

float last,i,x,y;
string choice;


//data input section
cout<<"The first  choice is Y=X^3-2X+10      select by typing 'first'\n";
cout<<"The second choice is Y=X^4+3X^2-15    select by typing 'second'\n";
cout<<"The third  choice is Y=X^2-10         select by typing 'third'\n";

cout<<"You may enter your choice\n";
cin>>choice;

cout<<"You may enter a starting value for X\n";
cin>>x;
cout<<"You may enter a stopping value for X\n";
cin>>last;
cout<<"You may enter the increment value for X\n";
cin>>i;

{
do
{
       cout<<"before X="<<x<<"\n";
       y=x*x*x-2*x+10;
       cout<< "The value for X is "<<x<<"\n";
       cout<< "You value for Y is "<<y<<"\n";
       cout<<"WRONG1\n";
       x=x+i;
       cout<<"after X="<<x<<"\n";
       cout<<"Choice="<<choice<<"\n";
}
while((x<=last)&&(choice =="first"));
}

{
do
{
       cout<<"before X="<<x<<"\n";
       y=x*x*x*x+3*x*x-15;
       cout<< "The value for X is "<<x<<"\n";
       cout<< "You value for Y is "<<y<<"\n";
       cout<<"wrong2\n";
       
       x+=i;
       cout<<"after X="<<x<<"\n";
       cout<<"Choice="<<choice<<"\n";
}
while((x<=last)&&(choice =="second"));
}

{
do
{
       cout<<"before X="<<x<<"\n";
       y=x*x-10;
       cout<< "The value for X is "<<x<<"\n";
       cout<< "You value for Y is "<<y<<"\n";
       cout<<"wrong3\n";
       x+=i;
       cout<<"after X="<<x<<"\n";
       cout<<"Choice="<<choice<<"\n";
}
while(x<=last&&choice =="third");
}


/**
{
do
{
cout<<"X="<<x<<"\n";
cout<<"Your input is invalid\n";
x+=i;
cout<<"X="<<x<<"\n";
}
while(choice !="first" && choice !="second" && choice !="third"&&x==i);
}
*/



system("pause");//this gives the press any key message
//that's the end
}
Topic archived. No new replies allowed.