#include <iostream>
#include <math.h>
using namespace std;
float f1(int low,int up)
{
int i,total=0.0;
for(i=low;i<=up;i++)
{
total=total+(i*i+i*1.5+4);
}
return total;
}
float f2(int low,int up)
{
int i,total=0.0;
for(i=low;i<=up;i++)
{
total=total+(i*i+i*1.5-4);
}
return total;
}
int main()
{
int low,up;
cout << "This program calculates the area under a curve
between two points on the x axis\n";
cout<< "\nThe FIRST equation is: f(x)=x^2 +1.5x +4";
cout<< "\nThe SECOND equation is: f(x)=x^2 +1.5x -4";
cout << "\nEnter x's minimum value : ";
cin >> low;
cout << "Enter x's maximum value : ";
cin >> up;
cout << "\nArea in square inches for FIRST equation\n";
cout << "The area under the curve between
"<<low<<" and "<<up<<" is:
"<<f1(low,up)<<" square inches.\n";
cout << "\nArea in square inches for SECOND
equation\n";
cout << "The area under the curve between
"<<low<<" and "<<up<<" is:
"<<f2(low,up)<<" square inches.\n";
return 0;
}
PART D) Make all of the user inputs “idiot proof.” PART E) Do a comparison study of the program. Meaning, the program will take more “time” when the number of x axis segments is larger. Also, the accuracy of the number should be greater, with more segments. In other words, you are trading off accuracy for run time. At what point does the number of segments provide improved accuracy vs. the “time” it take the program to execute? F) Have the user input a math equation and you do the calculations. Limit it to a fifth order polynomial equation. the important part is F can you please answer it for me. thanks
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
#include <iostream> #include <math.h> using namespace std; float f1(int low,int up) { int i,total=0.0; for(i=low;i<=up;i++) {...
Flow chart of this
program
#include <iostream> #include <cmath> using namespace std; int mainO double sum=0.0, ave-ee, int locmx, locmn int n; cout <<"Enter the number of students: "<<endl; cin >> ni double listln]; double max-0; double min-e; for (int i-e ; i<n ;i++) cout<s enter the gpa: "<cendli cin>>listli]; while (listlile i listli1>4) cout<s error,Try again "<cendl; cin>listlil: sun+=list[i]; N1 if (listli]>max) for(int isin itt) max=list [i]; 10cmx=1+1 ; else if (list [i] min) min=list [i]; locmn-i+1; ave sum/n;...
Consider the following C++ program: #include <iostream> using namespace std; void f1(int); void f2(int); void f3(int); int main() { f1(10); return 0; } void f1(int n) { f2(n + 5); } void f2(int n) { f3(n - 2); } void f3(int n) { cout << n << endl; // LINE 1 } Just before the program statement marked with the comment "LINE 1" is executed, how many stack frames will be on the program call stack?
Edit this C++ code to show the output as well.
#include<iostream>
#include<cstring>
using namespace std;
class Product {
private:
// private variables
int id_number;
char pDescription[40];
int mId;
double productPrice;
double productMarkUp;
int qty;
public:
// constructor
Product() {
id_number = 0;
strcpy_s(pDescription, "");
mId = 0;
productPrice = 0.0;
productMarkUp = 0.0;
qty = 0;
}
...
Fix the following program (C++). #include <iostream> #include <cmath> #include <vector> #include <limits> using namespace std; /* * Calculate the square of a number */ float square (float x) { return x*x; } /* * Calculate the average from a list of floating point numbers */ float average(vector<float>& values) { float sum = 0.0f; float average; for (float x : values) sum += x; average = sum / values.size(); return average; } /** Calculate the standard deviation from a vector...
#include <iostream> #include<cmath> using namespace std; int main() { float R = 8.314; // ideal gas constant in J/(mole-K) float F = 81; float C = (F-32)*5/9; float T = C + 273; cout << " 70 degree F = " << T << endl; double P = 13600*(30*2.54/1000)*9.81; // P density*g*h cout << " P : " << P << " Pascal " << '\n'; double V = 10*10*5; // volume in m^3 double k_B = 1.38E-23;...
Find two syntax errors in the following program: #include <iostream> using namespace std; int area(int length, int width = 0); int main() { int length, width; // for rectangle use both arguments cout << "Enter length and width of a rectangle" << endl; cin >> length >> width; cout << "The area is " << area(length, width) << endl; // for square, only need first argument cout << "Enter side of a square" << endl; cin >> length; cout <<...
This program illustrates dynamic variables #include <iostream> using namespace std; int main () { int *p1; p1 = new int; // Variables created using the new operator are called dynamic variables cout << "Enter an integer \n"; cin >> *p1; *p1 = *p1 + 7; cout << << "Your input + 7 = " << *p1 << endl; delete p1; // Delete the dynamic variable p1 and return the memory occupied by p1 to...
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
const int index = 5;
int head = 0;
string s[index];
int flag = 1;
int choice;
while (flag)
{
cout << "\n1. Add an Item in
the Chores List.";
cout << "\n2. How many Chores
are in the list.";
cout << "\n3. Show the list
of Chores.";
cout << "\n4. Delete an...
#include <iostream> #include <string> #include <stdio.h> using namespace std; /** The FeetInches class holds distances measured in feet and inches. */ class FeetInches { private: int feet; // The number of feet int inches; // The number of inches /** The simplify method adjusts the values in feet and inches to conform to a standard measurement. */ void simplify() { if (inches > 11) { feet = feet + (inches / 12); inches = inches % 12; } } /**...
How convert this c++ into C #include<iostream> #include <stdlib.h> using namespace std; void multiplication() { int num1; int c, num2, ans; cout<<"Enter difficulty level(1/2)\n"; cin>>c; if(c==1) { num1= rand() % 10; num2= rand() % 10; cout<<"what is"<<num1 <<"*"<<num2<<"?\n" ; cin>>ans while(ans!=(num1*num2)) { if(ans!=(num1*num2)) { cout<< "No. Please try again.\n"; cout<<"what is"<<num1 <<"*"<<num2<<"?\n" ; cin>>ans; } } } else if(c==2) { num1= rand() % 10+90; num2= rand() % 10+90; cout<<"what is"<<num1 <<"*"<<num2<<"?\n" ; cin>>ans; while(ans!=(num1*num2)) { if(ans!=(num1*num2)) { cout<< "No. Please...