How do I write this program. Its just your basic intro to computer science in ba
ID: 3689153 • Letter: H
Question
How do I write this program. Its just your basic intro to computer science in basic C++. Here is the problem: Modify the program to plot to curve y = 0.25 x3 -2x2 =3x=6 for x between 0 and 6 increments of 1.0.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int x, y;
char label [] = " y axis";
char axis[] = "+--------------------------------------------------->"';
char line [] = " | ";
cout << label << endl;
cout <<axis << endl;
for (x=1; x <=15; x++)
{
y = pow((x-8),2.0) +3;
line[y] = '*':
cout << line << endl;
line[y] = ' ';
}
return 0;
}
Explanation / Answer
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
//https://drive.google.com/file/d/0B-3j9moQVBhgVjl1eFBMeno3WDQ/view?usp=sharing
//Since chegg is not properly posting my code (Spaces are not showing in answer) check the code from google drive
//since I am not able to understand what is the correct function
// y = 0.25 x3 -2x2 doesn't make any sense
//hence I am assuming that you have written that line correctly
int main()
{
int x, y, set = 5;
char label [] = " y axis ";
char axis[] = "<--------------------------------------------------->";
axis[set] = '^';
char line[100];
cout << label << endl;
cout << axis << endl;
for (x=1; x <=6; x++)
{
strcpy(line, " ");
y = pow((x-8),2.0) +3;
line[set] = '|';
line[y+set] = '*';
cout << line << endl;
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.