473,385 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

NEED HELP FAST--Loops

Using the Newton-Raphson method, find the two roots of the equation 3x^2 + 2x -2=0. (Hint: There is one positive root and one negative root.)

(x+1) = x - (3x^2 +2x -2) / (6x +2) This is the equation given for the Newton-Raphson method.
Expand|Select|Wrap|Line Numbers

Head File
#include <iostream>
#include <cmath>
using namespace std;
#include "Newton.cpp"
#include "Euler.cpp"
#include "displaymenu.cpp"

Main Program File

#include "head.h"

int main(void) //Note…some code will be removed after buffering test.
{
//Declare all variables here that are needed to call/receive values for Exercises
double guess=1.0, root=0.0; //variables needed for Exercise 6.a. in case A.
double differs=0.000001, eApprox=0.0; //variables needed for case B.
char choice = 81; // 81 is decimal code for capital Q; 113 is lower case q
int enterkey;
do {
//Your displaymenu() function will replace the next 6 steps
cout <<"Call displaymenu and enter an a ";//desplaymenu()
choice = toupper(getchar( )); enterkey = getchar( );
cout << choice <<":"<< enterkey << endl;
switch (choice) // a decision structure to select only one case out of many
{
case 'A':
cout<<"Call Newton(given guess), returns and saves root\n "; // Exercise 6.a.
root=Newton(guess);
cout<<"Newton's root is: "<<root;
break;
case 'B':
cout<<"Call Euler(given differs), returns and saves eApprox\n"; // Exerrcise 3.
cout<<" differs is set to: "<<differs<<endl;
//eApprox = Euler(differs);
cout<<" eApproximate is: "<<eApprox<<endl;
break;
default: //input data validation intercepted here
if (choice != 'Q') // a decision structure to skip or enter next {block}
{cout << "\nIncorrect Choice: Enter (A,B, or Q as valid)\n";
}//endif
} // end switch

} while (choice != 'Q'); //end do-while

cout << " Fini\n";


system("pause");
return 0;
} // end main


Newton File My newton does not work at the moment.
double Newton(double x) // returns y = f(x)
{
double root;
int count;
for (count = 1; count < 10; count++);
{

cout<<" The x value of Newton is: "<<x<<endl;
cout<<"The root: "<<root<<endl;
root=x-((3(pow((x),2))+2x-2)/(6x+2));
}//end for
return root;

} //end Newton

I still didnt make the Euler file or displaymenu file.
Oct 16 '08 #1
1 1310
gpraghuram
1,275 Expert 1GB
Please dont double post .

raghu
Oct 16 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Sofia | last post by:
My name is Sofia and I have for many years been running a personals site, together with my partner, on a non-profit basis. The site is currently not running due to us emigrating, but during its...
6
by: Robert Maas, see http://tinyurl.com/uh3t | last post by:
System login message says PHP is available, so I tried this: http://www.rawbw.com/~rem/HelloPlus/h.php It doesn't work at all. Browser just shows the source. What am I doing wrong?
0
by: Gregory Nans | last post by:
hello, i need some help to 'tree-ify' a string... for example i have strings such as : s = """A(here 's , B(A ) silly test) C(to show D(what kind) of stuff i need))""" and i need to...
7
by: Mike Kamermans | last post by:
I hope someone can help me, because what I'm going through at the moment trying to edit XML documents is enough to make me want to never edit XML again. I'm looking for an XML editor that has a...
8
by: JustSomeGuy | last post by:
I need to write an new class derived from the list class. This class stores data in the list to the disk if an object that is added to the list is over 1K in size. What methods of the std stl...
15
by: drdoubt | last post by:
using namespace std In my C++ program, even after applying , I need to use the std namespace with the scope resolution operator, like, std::cout, std::vector. This I found a little bit...
9
by: sk | last post by:
I have an applicaton in which I collect data for different parameters for a set of devices. The data are entered into a single table, each set of name, value pairs time-stamped and associated with...
3
by: Bob.Henkel | last post by:
I write this to tell you why we won't use postgresql even though we wish we could at a large company. Don't get me wrong I love postgresql in many ways and for many reasons , but fact is fact. If...
4
by: Scott Holland | last post by:
HELP - Need to connect to DB2 database on AIX from NT server. Also AS/400 from NT Server -- I am experienced in ORACLE and a novice at DB2. What tools would be the equivalent of Net*8 or...
0
by: U S Contractors Offering Service A Non-profit | last post by:
Brilliant technology helping those most in need Inbox Reply U S Contractors Offering Service A Non-profit show details 10:37 pm (1 hour ago) Brilliant technology helping those most in need ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.