- #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 1891 Ganon11 3,652
Recognized Expert Specialist
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 HTML below.
<input type="file" size="25" maxlength="256" id="filename" onchange="AddFile()"
/>
The problem I have is that the javascript function AddFile() is only run under
|
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"
source="http://www.microsoft.com/learning/syllabi/en-us/2555Afinal.mspx">
<module id="1" title="Introducing Windows Forms"
location="D:\Disk-C\Documents and Settings\orit_itzhar.ATRICA\My
Documents\XML\csharp">
<lesson id="1.1">
<subject>Creating a...
|
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 problem?
Thanks in advance for any help.
|
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 List<RoleData> GetRoles()
{
return GetRoles(null, false);
}
|
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 input to a file (when I
open the file, it's in the correct font), but I can't get PHP to read
the file and display the correct characters.
HTML --------------- Form
| |
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 seems to be the problem. These are video files and are
enormous with long crazy names so trying to hand type the file name in
a text box is not an option. So I'm using an Input "file" control so
when the user browses out onto the network...
|
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 have been successfully registered.</div>");
within 1.5 seconds.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta...
|
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 createNewFile($name,$mail,$subject,$comments,$count,$date,$other="",$up="0") {
global $settings;
$header=implode('',file('header.txt'));
$footer=implode('',file('footer.txt'));
$content='
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
|
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 from user to calculate the score.
Here is a problem.
I can read a text file. However, it's read whole file at a time. So,
|
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) parameter tile
the problem is, i can't give the runtime input as am a in need of creating a standalone product without user interaction.
the parameters in the parameter file is assigned as the input by "FILE" pointer concepts ...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |