- #include <iostream>
-
#include <fstream>
-
-
using namespace std;
-
-
int main()
-
{
-
cout << fixed << showpoint;
-
-
float a0,a1,a2,a3,a4,a5,a6,a7,a8; // Nine constant values in the polynomial
-
float x; // Value for x in the polynomial
-
float Polynomial; // Value for the polynomial
-
ifstream inData; // declares input stream
-
ofstream outData; // declares output stream
-
string fileName; // Inputs file name
-
-
cout << "This program computes and outputs the result of the polynomial" << endl;
-
cout << "The values for a8,a7,a6,a5,a4,a3,a2,a1,a0 and x are read from " << endl;
-
cout << "inputfile.dat and the outputs are written to outputfile.dat" << endl;
-
-
cout << "Enter the input file name: "; // Prompt
-
cin >> fileName; // Inputs the file name
-
inData.open(fileName.c_str()); // Opens the input file with the name
-
-
outData.open("outputfile.dat");
-
// binds program variable outData to the output file "outputfile.dat"
-
-
// Inputs values of a and x for the polynomial function
-
inData >> a8 >> a7 >> a6 >> a5 >> a4 >> a3 >> a2 >> a1 >> a0 >> x;
-
-
// The function of the polynomial and it calculates the result of the function
-
Polynomial = (a8*pow(x, 8)) + (a7*pow(x, 7)) + (a6*pow(x, 6)) + (a5*pow(x, 5))
-
+ (a4*pow(x, 4)) + (a3*pow(x, 3)) + (a2*pow(x, 2)) + (a1*x) + a0;
-
outData << Polynomial << endl; // Prints the result of the polynomial
-
-
return 0;
-
}
this program i made it to ask me to type the name of the inputfile that will be created but it is not created i typed inputfile.dat but it is not there what is wrong with it help!
1 1871
Well, you shouldn't be creating an input file at all - a new input file would be empty, so no data could be given to the program. Make sure inputfile.dat is already made in the same folder as the program, and fill it with the polynomial coefficients and the x value.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: @lias |
last post by:
Hi all
I have a webpage where I want the user to input filenames. To make this easier,
I use a file input type so that the user can select files rather than typing in
the filename, using the...
|
by: orit |
last post by:
I have the following xml file:
<?xml version="1.0" encoding="utf-8" ?>
<course id="2555" title="Developing Microsoft .NET Applications for Windows
(Visual C# .NET)" length="5 days"...
|
by: Nina |
last post by:
I have a text file which stores user input. Later if user edited the input
data from a input form. How can I update the input text file? If update the
text file too often, would it cause...
|
by: Learner |
last post by:
Hello,
Here is the code snippet I got strucked at.
I am unable to convert the below line of code to its equavalent vb.net
code. could some one please help me with this?
static public...
|
by: HaggMan |
last post by:
I'm creating a page that:
- accepts user input in whatever language
- saves that input to a file
- reads the file and displays the original input
The following code successfully writes the user...
|
by: kevin |
last post by:
Hi, I am trying to create a page so the user can browse the network,
select a file and have that file name (text) inserted into our sql DB
so I can build the hyperlink path later on.
Here's what...
|
by: sufian |
last post by:
Below is the field where user enters his/her email address and the AJAX post request is sent to the server and the user sees the message:
echo("<div id=\"message\" class=\"success\">Thank you! You...
|
by: eragon |
last post by:
I wrote this function to create a new file when the user posts in my forums, and its not creating a new file, can you help me? this script is not copyrighted as the last one.
function...
|
by: portCo |
last post by:
Hello there,
I am creating a vb application which is some like like a questionare.
Application read a text file which contains many questions and display
one question and the input is needed...
|
by: aswinikg |
last post by:
HI
I am a newbie to 'C' and embedded application . I have a code in which the input parameter is being assigned in two ways
(i) Runtime through user
(ii)...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |