i want to do program that calculat percentage of error

percentage of error ={ X ( calculated) * X ( measuered) } * 100 / { X ( measuered)}
and if the result more than or equal 50 it is bad
if it is less than 50 til 20 it is good
if it is less than 20 it is excelente


the programe must have ( if , case , while , switch, functions)

i relly need help

all what i know

i will write it down
so i wish to help me


# include < iostream>
using namespace std;
int main ( void)
int main (math.h)

for(i==50

cout <<" enter your x calculated"<<\n;
cin>> x calculated
cout <<" enter x measured"<<\n;
cin>> X measured;


if(x==>50);
cout<< "bad result"<<;
if else( x=<50, x==>20);
cout<<" good result";

else( x=<20)
cout<<" excellent result"<<;

Where to begin... The code you posted is barely recognizable as C++...

I suggest you dump the entire code in the trashbin. I'll give you a small part of the code to get you started

#include <iostream>

using namespace std;

int main()
{
	int measured = 0, calculated =0;
	cout << "enter measured: \n";
	cin >> measured;
	cout << "enter calculated: \n";
	cin >> calculated;

	cout << "you entered: " << measured << " and:  " << calculated << endl;
	cin.ignore();
	cin.get();
	return 0;
}

Now try to modify the above and come back if you have any questions.

[edit]
And please post your code between [code=cpp] //your code here [/code] tags. That way it gets color and line-number, so that we can actually read what you posted

i approciate what you give me to start but , iam looking for the conditions and cases how i can do them ..?


plz help me i need them

Check these links:

if statements
switch ()
loops

You might want to read the rest of the tutorial as well.

I hope this is your very first assignment, because if it's not, you'll have a very very hard understanding the rest of the classes.

Here's an example of an if-statement.

#include <iostream>
using namespace std;

int main()
{
	int measured = 0;
	cout << "enter measured: \n";
	cin >> measured;

	if (measured > 50)
	{
		cout << "you entered something bigger then 50 \n";
	}
	else 
	{
		cout << "you entered something smaller then 51 \n";
	}
        cout << "This line will always be displayed \n";
	cin.ignore();
	cin.get();
	return 0;
}

thank you for help my brother

i wish from you to read what i mention in the first

i didnt say that measured less or equal 50

i was talking about result


i need only the way of programming this formula :(

percentage of error ={ X ( calculated) * X ( measuered) } * 100 / { X ( measuered)}

i wish from you to read what i mention in the first

i didnt say that measured less or equal 50

i was talking about result

I readthat, I'm not stupid.

I gave you an example in the hope that you would see the logic behind 'if statements' and write some decent code yourself.
We don't give away free homework, we only help you write it yourself.

So try to modify the program I gave you and come back with what you came up with

#include <iostream> 
using namespace std;
 int main()
{   
int xmeasured = 0, xcalculated =0;
    cout << "enter measured: \n"; cin >>xmeasured;
    cout << "enter calculated: \n";   cin >> xcalculated; 
    cout << "you entered: " << measured << " and:  " << calculated << endl;   
cin.ignore();   
cin.get();  
return 0;
}


{
int result;
int xcalculated;
int xmeasured;
 result=((xcalculated-xmeasured)/xmeasured)*100;
}



if(result >=50)
{ 
cout<<" the result is bad\n"
}
else if ( result <50)
{
cout<<" the result is good\n"
}


return 0;

it dosnt work

what should i do
help me , plz

#include <iostream> 
using namespace std;
 int main()
{	
int xmeasured = 0, xcalculated =0;
	cout << "enter measured: \n";	cin >>xmeasured;
	cout << "enter calculated: \n";	cin >> xcalculated; 
	cout << "you entered: " << measured << " and:  " << calculated << endl;	
cin.ignore();	
cin.get();	
return 0;
}


{
int result;
int xcalculated;
int xmeasured;
 result=((xcalculated-xmeasured)/xmeasured)*100;
}



if(result >=50)
{ 
cout<<" the result is bad\n"
}
else if ( result <50)
{
cout<<" the result is good\n"
}


return 0;

it dosnt work

what should i do
help me , plz

This isn't a program. Everything after line 12 is just floating around and is not in a function. You either need to stick that code in main somewhere or write a function and put it in there.

how many program have you done in class even if they are tutorials...your missing ";" at ends of your statments and the rest of your code is not in any function and neither is it in the main function

ok , guide me
i doont know why you are repeatingn that

tell what should i do and how ????


thank for all

tell what should i do and how ????

I think you should study from the very beginnings of C++. See
http://www.cprogramming.com/tutorial.html#c++tutorial
for a beginner's tutorial, especially pay attention to topics you need "if , case , while , switch, functions".
Take your time to go through it, and maybe post questions regarding the things you cannot figure out.

#include "stdafx.h"
#include < iostream>
#include "stdlib.h"
#include "conio.h"
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	double Xcalculated, Xmeasured, Error;
	cout <<" enter your x calculated\n";
	cin>> Xcalculated;
	cout <<" enter x measured\n";
	cin>> Xmeasured;
	Error = abs((Xmeasured/Xcalculated-1)*100); //For the Percentage of Error, we need the Absolute value
	if(Error>=50)
	{
		printf("Bad result, the Percentage of error = %.2f ", Error);
	}
	if(Error<50 && Error>20)
	{
		printf("Good result, the Percentage of error = %.2f ", Error);
	}
	if(Error<=20)
	{
		printf("Excellent result!!, the Percentage of error = %.2f ", Error);
	}
	getch(); //A function that waits for a key pressed (enter or whatever)
	return 0;
}

Hope that helps you... the While Loop and the Case are probably to be used if you want to add a Question about repeating the program (Would you like to recalculate? [Y/N]) You'll repeat while the User has pressed 'Y'
.... I was too lazy to program that so good luck... just do some more research.... half of the program is done!!

Soo... what happened with your homework?? Were you able to figure it out??/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.