Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- #include <stdio.h>
- #include <conio.h>
- #include <stdlib.h>
- #include <unistd.h>
- #include <cstdlib>
- #include <string.h>
- using namespace std;
- void quad(void)
- {
- double a = 0, b = 0, c = 0;
- clrscr();
- cout<<"\xDB";
- cout<<" please input A\n";
- cin>>a;
- cout<<"please input B\n";
- cin>>b;
- cout<<"please input C\n";
- cin>>c;
- system("cls");
- cout<<"Your equation is ("<<a<<")x^2 + ("<<b<<")x + ("<<c<<")";
- cin.get();
- cin.get();
- clrscr();
- double x1=(-b + sqrt(pow(b,2) - 4*(a*c)))/(2*a);
- double x2=(-b - sqrt(pow(b,2) - 4*(a*c)))/(2*a);
- double d = (pow(b,2) - 4*(a*c));
- if(d > 0) {
- cout<<"\nYour (X)-intercepts are : \n"<<x1<<" and "<<x2;
- cin.get();
- }
- else if(d == 0){
- cout<<"You have one (X)-intercept";
- cin.get();
- }
- else if (d < 0){
- cout<<"You do not have an (X)-intercept";
- cin.get();
- }
- }
- void add (void)
- {
- double a = 0, b = 0, c = 0;
- clrscr();
- cout<<" Please input the two numbers you would \n like to add\n input :\n ";
- cin>>a;
- cout<<"\n ";
- cin>>b;
- c = a+b;
- cout<<"\n The answer is "<<c;
- cin.get();
- cin.get();
- }
- void sub (void)
- {
- double a = 0, b = 0, c = 0;
- clrscr();
- cout<<" Please input the two numbers you would \n like to subtract\n input :\n ";
- cin>>a;
- cout<<"\n ";
- cin>>b;
- c = a-b;
- cout<<"\n The answer is "<<c;
- cin.get();
- cin.get();
- }
- void trig (void){
- double a = 0, b = 0, c = 0;
- clrscr();
- cout<<"please input A";
- cin>>a;
- cout<<"please input B";
- cin>>b;
- clrscr();
- c = sqrt(pow(b,2)+pow(a,2));
- cout<<" Your answer is "<<c;
- cin.get();
- cin.get();
- }
- void perc (void)
- {
- double number, percent, result;
- clrscr();
- cout<<"please input the base number :";
- cin>>number;
- clrscr();
- cout<<"please input your percent :";
- cin>>percent;
- result = number * 100;
- result = (result / 100) * percent;
- result /= 100;
- cout<<"your answer is "<<result;
- cin.get();
- cin.get();
- }
- void slope (void){
- clrscr();
- float y1, y2, m, x1, x2, b;
- char x, y;
- cout<<"Enter first X: ";
- cin>> x1;
- cout<<"Enter second X: ";
- cin>> x2;
- cout<<"Enter first Y: ";
- cin>> y1;
- cout<<"Enter second Y: ";
- cin>> y2;
- m=(y2-y1)/(x2-x1);
- cout<<"The slope is: "<< m <<"\n";
- cin.get();
- b=y1-(m*x1);
- cout<<"The y intercept is: "<< b <<"\n";
- cout<<"The line equation is: "<< "y="<<m<<"x+"<<"("<<b<<")"<<"\n";
- cin.ignore();
- cin.get();
- }
- void prime (void){
- int i, n;
- cout <<" enter a possitive integer";
- cin>>n;
- for(i = 2; i <= n / 2; i++)
- {
- if(n % i == 1)
- {
- cout<<n;
- cin.get();
- }
- }
- }
- int main(){
- for(;;)
- {
- clrscr();
- cout<<" Please select what type of function \n you would like to use.\n 'q' - Quadratic Formula\n 'a' - Addition\n 's' - Subtraction\n 'p' - Percent\n 't' - Pythagorean theorem\n 'f' - Slope of a line\n Input :";
- char q;
- cin>>q;
- switch(q){
- case 'q' :
- quad();
- break;
- break;
- case 'a' :
- add();
- break;
- break;
- case 's' :
- sub();
- break;
- break;
- case 't' :
- trig();
- break;
- break;
- case 'p' :
- perc();
- break;
- break;
- case 'f' :
- slope();
- break;
- case 'r' :
- prime();
- break;
- default :
- clrscr();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement