#include <iostream.h>

#include <conio.h>

#include <math.h>

void main()

{

float x, y, number_x, number_y, average_x, average_y, sum_x=0, sum_y=0, A, sum_A=0, B;

float sum_B=0, m1, m2, m3, c, range_x, range_y;

float y_min_marks=12345678;

float y_max_marks=1;

float x_min_marks=12345678;

float x_max_marks=1;

char next= 'y';

cout<<"This program is use to find the equation that fit the plotted lines.";

cout <<"\nType 'y' if you want to continue.";

cin >> next;

while (next=='y')

{

cout << "\nPut in the (x), and (y) ";

cin >> x >> y;

A = x*y ;

B = x*x ;

if(x<x_min_marks)

x_min_marks=x;

if(x>x_max_marks)

x_max_marks=x;

sum_x = sum_x + x;

number_x = number_x + 1;

if(y<y_min_marks)

y_min_marks=y;

if(y>y_max_marks)

y_max_marks=y;

sum_y = sum_y + y;

number_y = number_y + 1;

sum_A = sum_A + A ;

sum_B = sum_B + B ;

cout << "Type 'y' if you want to continue.";

cin >> next;

}

average_x = sum_x/number_x;

range_x = x_max_marks - x_min_marks ;

range_y = y_max_marks - y_min_marks ;

cout << "\n\nThe range of x is " << range_x << endl;

average_y = sum_y/number_y;

cout << "The range of y is " << range_y << endl;

m1 = sum_A - (sum_x * average_y);

m2 = sum_B - (sum_x * average_x);

m3 = m1/m2 ;

cout << "\nThe gradient of the plotted line is " << m3 << endl;

c = average_y - (m3 * average_x);

cout << "\nThe y-intercept of this line is " << c << endl;

cout << "The equation of this line is";

cout << "\nY = " << m3 << "x + " << c << endl;

getch();

}

p/s:

Hello there and assalamulaikum eveybody~

This is my first programming/c++ assignment.

The program above is use to calculate gradient and y-intercept of a line.

The line is obtain from a series of x and y points which is then plotted. Then, they all form lah plotted line.

To use this program is really simple, you just need to read in (type in) a series of x and its pair (y value), and then finished. The program will calculate anything for you and directly give smooth and correct precise equation! It is super wonderful right. ^_^

One of my friends got hard-copy of this from me (when I'd finished it down),

she give this to my lecturer, and she (my lecturer) said what that I'd already done is correct.

yahhuu, alhamdulillah, happiness blooms me for sometime ^_^.

Today I'm studying a lot of biochemistry,

I'm going through 2 chapters today which are Amino Acid (chap.4) and pH and Buffers (chap.5).

The upcoming test is on next tuesday. InsyAllah I will do my best. Do pray for me okay dear readers.

Quite almost all the time thinking of it.

Between 9 o'clock and 11pm, I'd a bit of Malay Formal Language discussion (is it correct how I translated it? haha) with my fellow groupmates.

Yahh, I have to admit that Bahasa Melayu (Malay Formal Language) is one of the toughest course.

InsyAllah will study a bit more of it.

and right now, I'm going to write my 300 pages English essay, (quite short aite?), about compare and contrasts (between anything).Okay, right now I'd just written for an about 150 words, and starts to feel, a lil' bit sleepy right now..

Conlusion:

Quite excited for this upcoming midsem holidays. I must try to live based on syariah.

Yeah, really sorry for what was happening. Hope 'you' alwayss in good condition.

Biochemistry post is waiting!

## No comments:

## Post a Comment