Welcome
Welcome to the forums of AntiRTFM's Absolute N00b Spoonfeed C++ Tutorials!

You are currently viewing our boards as a guest, which gives you limited access to view most discussions and access our other features. By joining our free community, you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content, and access many other special features. Registration is fast, simple, and absolutely free, so please, <a href="/profile.php?mode=register">join our community today</a>!

Project 1

Here are some projects of actual programs you can practice making.

Re: Project 1

Postby pipey85 on Wed Jul 01, 2009 8:01 am

EDIT: sorry double post :oops:
Last edited by pipey85 on Fri Jul 03, 2009 5:56 pm, edited 1 time in total.
Pardon my n00bness, what I lack in C++ I make up for in time spent reading about C++ :P
pipey85
 
Posts: 40
Joined: Mon Jun 22, 2009 6:11 pm

Re: Project 1

Postby Silvershaft on Fri Jul 03, 2009 5:24 pm

Here is my, I have been learning c# before also a little. But I moved to c++ because it is really easy to learn from these tutorials rather than from a book.
I also sent my calculator to some of my friends and they liked it :)

Btw some function name and some words can be finnish for me to understand better.

Code: Select all
#include "stdafx.h"

#include <iostream>
#include <string>

using namespace std;

int main()
{
   double firstnum;
   double secondnum;
   char opperator;
   char f;
   int alkuun();


   cout << "Please type your first number: ";
   cin >> firstnum;
   cout << "Ok good now enter operator (+,-,*,/): ";
   cin >> opperator;
   cout << "Operator given, now give second number: ";
   cin >> secondnum;
   cout << "Numbers and operator given and \nAnswer is: ";

   if ( opperator == '+' )
   {
      cout << firstnum << " + " << secondnum << " = " << firstnum + secondnum << endl;
   }

   else if ( opperator == '-' )
   {
      cout << firstnum << " - " << secondnum << " = " << firstnum - secondnum << endl;
   }

   else if ( opperator == '*' )
   {
      cout << firstnum << " * " << secondnum << " = " << firstnum * secondnum << endl;
   }

   else if ( opperator == '/' )
   {
      cout << firstnum << " / " << secondnum << " = " << firstnum / secondnum << endl;
   }
   alkuun();


}


int alkuun()
{
   string answer;

   cout << "If you want to start again type yes or if you want to quit write no.\nEnter your answer: ";
   cin >> answer;


   if ( answer == "yes" )
   {
      main();
   }
   else if ( answer == "no" )
   {
      goto Loppu;
   }
   else if ( answer != "no" && answer != "yes" )
   {
      cout << "Enter proper answer!" << endl;
      alkuun();
   }

Loppu:

   return 0;
}
Silvershaft
 
Posts: 29
Joined: Fri Jul 03, 2009 5:13 pm

Re: Project 1

Postby learning in progress on Sun Jul 12, 2009 11:51 am

Code: Select all
#include "stdafx.h"
#include <iostream>

using namespace std;

int main ()

{

   double number;
   
   double number2;
   
   char choice;
   
   cout << "\n";
   
   cout << "Welcome to Calculator\n";
   
   cout << "\n";
   
   cout << "Enter your first number:";
   
   cin >> number;
   
   cout << "\n";
   
   cout << "Enter your operation sign (+,-,/,*):";
   
   cin >> choice;
   
   cout << "\n";
   
   cout << "Enter your second number:";
   
   cin >> number2;
   
   cout << "\n";
   
   
   cout << number << choice<<number2<<"=\n";
   
   cout << "\n";
   
   if (choice == '+') cout <<(number+number2);
   
   else if (choice == '-') cout << (number - number2);
   
   else if (choice == '*') cout  << (number * number2);
   
   else if (choice == '/') cout << (number / number2);
   
   cout << "\n";
   
   cout << "\n";
   
   cout << "Thanks for using my calculator!\n";
   cout <<"Want to use it again?(y/n)";
   char again;
   int x=1;
   cin >> again;
   for (;again=='y'&& x==1;main()){x++;}
   for (;again !='y';){break;}
      
   
   char g;
   
   cin >> g;
   
   return 0;
   
}   
   


this is what i made
the program seem to run fast
but in the end when it asks to do it again
if i hit y it starts
and when i try hit n after running it 3 or 4 times
i need to type n 4 times to exit :?:
learning in progress
 
Posts: 11
Joined: Thu Jul 09, 2009 4:15 pm

Re: Project 1

Postby stclark08 on Wed Jul 29, 2009 3:43 pm

stclark08
 
Posts: 1
Joined: Wed Jul 29, 2009 3:40 pm

Re: Project 1

Postby c-- on Thu Jul 30, 2009 6:49 pm

Code: Select all
#include "stdafx.h"
#include <iostream>
using namespace std ;


   
   int main ()
{

   int number;
   int number2;
   char choice;

   cout << "Choose a number \n";

   cin >> number;


   cout << "awesome, now pick an operation. Add + subtract - multiply * or devide / \n" ;

      cin >> choice;
   
   cout << " Great now choose another number \n";
    
      cin >> number2;



      if ( choice == '+')
      {
         cout << "your answer is : ";
         
         cout << number + number2;
      }
      
        if ( choice == '-')
      {
        cout << "your answer is : ";
         
         cout << number - number2;
      }
      
      if ( choice == '/')
      {
        cout << "your answer is : ";
         
         cout << number / number2;
    
         
      }
      
      if ( choice == '*')
      {
       
         cout << "your answer is : ";
         
         cout << number * number2;
      }

    
      
      
      
      
      
   char f;
   cin >> f ;
   return 0 ;
}

c--
 
Posts: 2
Joined: Sun Jul 26, 2009 12:51 pm

Re: Project 1

Postby Zolga on Sat Aug 01, 2009 6:35 pm

I think I did it right
Code: Select all
#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{
   float one;
   float two;
   char math;
   cout << "Type in your first number: ";
   cin >> one;
   cout << "Do you want to Add +, Subtract -, Multiply * or Divide /\n";
   cout << "Type your choice here: ";
   cin >> math;
   cout << "Type in your second number:";
   cin >> two;
   if(math == '+')
   {
      cout << "Your answer is: " << one << math << two << "=" << one + two << endl;
   }
   if(math == '-')
   {
      cout << "Your answer is: " << one << math << two << "=" << one - two << endl;
   }
   if(math == '*')
   {
      cout << "Your answer is: " << one << math << two << "=" << one * two << endl;
   }
   if(math == '/')
   {
      cout << "Your answer is: " << one << math << two << "=" << one / two << endl;
   }
   char o;
   cin >> o;
   return 0;
}
Zolga
 
Posts: 2
Joined: Sat Aug 01, 2009 6:32 pm

Re: Project 1

Postby DevGeek++ on Tue Aug 04, 2009 7:35 pm

What do you think about mine ? :P I am beginner :D

Code: Select all
#include <iostream>

using namespace std;

int main()
{
    int choice;
    float num1;
    float num2;

do {
    cout <<"(1) - Addition" << endl;
    cout <<"(2) - Subtraction" << endl;
    cout <<"(3) - Multiplication" << endl;
    cout <<"(4) - Division" << endl;
    cout <<"(5) - Quit" << endl;
    cout << endl;
    cin >> choice;
}
    while (choice <= 0 || choice >= 6 );
    cout << endl;
    cout <<"Number : ";
    cin >> num1;
    cout << endl;
    cout <<"Number : ";
    cin >> num2;
    cout << endl;
    switch (choice) {
        case 1:
            cout << num1 << " + " << num2 << " = " << num1+num2 << endl;
            break;
        case 2:
            cout << num1 << " - " << num2 << " = " << num1-num2 << endl;
            break;
        case 3:
            cout << num1 << " x " << num2 << " = " << num1*num2 << endl;
            break;
        case 4:
            cout << num1 << " : " << num2 << " = " << num1/num2 << endl;
            break;
        case 5:
            return 0;
            break;
}

    system("PAUSE");
    return 0;
}
DevGeek++
 
Posts: 28
Joined: Tue Aug 04, 2009 5:54 am

Re: Project 1

Postby Zolga on Mon Aug 10, 2009 3:03 pm

After watching your switches video, I changed it
Code: Select all
// Example.cpp : Defines the entry point for the console application.
//

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

int main()
{
   float one;
   float two;
   char math;
   cout << "Type in your first number: ";
   cin >> one;
   cout << "Do you want to Add +, Subtract -, Multiply * or Divide /\n";
   cout << "Type your choice here: ";
   cin >> math;
   cout << "Type in your second number:";
   cin >> two;

   switch(math)
   {
   case '+':
      cout << "Your answer is: " << one << math << two << "=" << one + two << endl;
      break;
   case '-':
      cout << "Your answer is: " << one << math << two << "=" << one - two << endl;
      break;
   case '*':
      cout << "Your answer is: " << one << math << two << "=" << one * two << endl;
      break;
   case '/':
      cout << "Your answer is: " << one << math << two << "=" << one / two << endl;
      break;
   }

   char yesno;
   cout << "Do you want to start again? Y/N \n";
   cout << "Type your choice: ";
   cin >> yesno;
   if (yesno == 'Y')
   {
      main();
   }
   return 0;
}
Zolga
 
Posts: 2
Joined: Sat Aug 01, 2009 6:32 pm

Re: Project 1

Postby CPlusPlusNOOB on Tue Aug 11, 2009 3:52 pm

Here's my first go at C++.

Code: Select all
#include "stdafx.h"

#include <iostream>

using namespace std;

int main()
{
   float userFirstNumber = 0;
   float userSecondNumber = 0;
   char mathOperator = ' ';
   char exit;

   cout << "Simple Calculator" << endl << endl;
   cout << "Please enter first number: ";
   cin >> userFirstNumber;
   cout << endl << "Select a mathematical operator (+, - , * , /): ";
   cin >> mathOperator;
   cout << endl << "Please enter second number: ";
   cin >> userSecondNumber;

   if (mathOperator == '+')
      cout << endl << endl <<  userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = "  << userFirstNumber + userSecondNumber;
   else if (mathOperator == '-')
      cout << endl << endl <<  userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber - userSecondNumber;
   else if (mathOperator == '*')
      cout << endl << endl <<  userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber * userSecondNumber;
   else if (userSecondNumber == 0)
   {
      cout << "Divide by zero is illegal";
      cout << endl << "Please try again!" << endl << endl;
      main();
   }
   else
      cout << endl << endl <<  userFirstNumber << " " << mathOperator << " " << userSecondNumber << " = " << userFirstNumber / userSecondNumber;

   cout << endl;
   cin >> exit;

   if (exit == 'x')
      return 0;
}
CPlusPlusNOOB
 
Posts: 1
Joined: Tue Aug 11, 2009 3:43 pm

Re: Project 1

Postby cezaridox on Tue Aug 18, 2009 1:42 pm

Code: Select all
#include<iostream>
#include<cmath>
using namespace std;

int main()
{
    char z;
    double a,b;
   
    cout <<"\n";
    cout <<"                               CALCULATOR  +-*/" <<"\n";
    cout <<"================================================================================" <<"\n";   
    cout <<"\n";   
    cout <<"\n";
do{
       
        cout <<"Input number A : ";
        cin  >> a ;
        cout <<"Input number B : ";
        cin  >> b ;
        cout <<"    Chose operation: ";
        cin  >> z;
     
    if( z == '+' )
      {
      cout<<" Result: "<< a << " + "<< b <<" = "<<a+b<<"\n";
       goto intrebare;
      }
    else if( z == '-')
      {
      cout<<" Result: "<< a << " - "<< b <<" = "<<a-b<<"\n";
       goto intrebare;
       }
    else if( z == '*')
      {
      cout<<" Result: "<< a << " * "<< b <<" = "<<a*b<<"\n";
       goto intrebare;
       }
    else if( z == '/')
      {
      cout<<" Result: "<< a << " / "<< b <<" = "<<a/b<<"\n";
      goto intrebare;
       }
    else
      {
      cout<<" Invalid sign!!"<<endl;     
      intrebare:
      cout<<" Do you whant another try?Y/N: ";
      cin>> z;     
      }     
    }while((z == 'y')&& !(z =='n'));
       
   system("pause");
   return 0;
}

:roll:
Last edited by C++ on Tue Aug 18, 2009 5:07 pm, edited 1 time in total.
Reason: Please put code between tags [code] Your code here... [/code]
cezaridox
 
Posts: 2
Joined: Tue Aug 18, 2009 11:15 am

Re:

Postby ramononline on Thu Aug 27, 2009 1:12 am

antiRTFM wrote:adrian++

Excellent job!


bad program.... i entered " n " at begining of program and it crashed ...closed window berfore stoping program.... caused somthing to malfunction in ap32 .... my fault also but now im upset.... so beware every one else.
Razor Ra
ramononline
 
Posts: 2
Joined: Tue Aug 25, 2009 12:55 am

Re: Re:

Postby C++ on Thu Aug 27, 2009 6:39 am

ramononline wrote:
antiRTFM wrote:adrian++

Excellent job!


bad program.... i entered " n " at begining of program and it crashed ...closed window berfore stoping program.... caused somthing to malfunction in ap32 .... my fault also but now im upset.... so beware every one else.


You are quoting a post from May 18, 2008...

You have to keep in mind that these programs are not made by C++ experts. Learning is done in steps. You can't expect novice programmers to program a perfect program on the first try. This program works fine unless you enter invalid input. It does not crash, but simply loops forever because the input stream goes into a fail state. Every C++ programmer should know how to properly get user input, that's why my signature contains a link to a topic I made, to help newcomers to C++.

This program is not bad. It fails on catching invalid user input. Giving feedback is a good thing, however your feedback is what I call unconstructive criticism.
If you only feel the need to give criticism, then at least provide the programmer with information on how to improve his/her program, otherwise please keep your criticism to yourself.
New to C++ programming? Click here
C++
teh awesome
 
Posts: 217
Joined: Sun May 25, 2008 7:45 am

Re: Project 1

Postby tundra364 on Sat Aug 29, 2009 4:04 am

this was my "try" to make a cardulator. this is about my 2nd set of codes i made. so if i did anything wrong plz. holla at me


Code: Select all
#include "stdafx.h"

#include <iostream>

using namespace std;

int main()

{
   
   char response;

   int y;

   int z;

   

   cout << "input the 1st number:";

   cin >> y;

   cout << "input the action you would like to take \n";

   cin >> response;

   cout << "input the 2nd number";

   cin >> z;

   

   if (response == '+')
   {cout << y << "+" << z << "=" << endl <<"the answer is:" << y + z;}

   if (response == '-')
   {cout << y << "-" << z << "= \n" << "the answer is:" << y - z;}

   if (response == '*')
   {cout << y << "*" << z << "=" << endl << "the answer is:" << y * z;}

   if (response == '/')
   {cout << y << "/" << z << "= \n" << endl << "the answer is:" << y / z;}

   cout << endl;

   cout << " press any letter and enter to exit the progam:";



   char f;

   cin >> f;

   return 0;




}
tundra364
 
Posts: 1
Joined: Sat Aug 29, 2009 3:57 am

Re: Project 1

Postby sawm on Sat Aug 29, 2009 2:00 pm

bare with me i know there's alot too long stuff could have used switch statement and all but i wanted to test stuff out this is far from good and i know it so don't tell me i suck because i know -_-' but instead tell me what i could have done better like how i could make my program not crash/infinite loop wen i type a char? :( well hope this was what i had to do xD
-sawm <3-

p.s sorry if its messy :(


Code: Select all
// just a simple calculator by: Sawm
#include <iostream>
#include <windows.h>
#include <string>
using namespace std;

void addition()
{
     int long firstNumber, secondNumber, total;
    cout<<"\n Welcome to the ADDITION calculator who will add 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
    cout<<"  First Number:";
    cin>> firstNumber;
    cout<<"        +     \n";
    cout<<" Second Number:";
    cin>> secondNumber;
    cout<<"\n\n\n";
    cout<<"Awnsser:";
    total = firstNumber + secondNumber;
    cout<<"\n"<< firstNumber <<" + "<< secondNumber << " = " << total ;
    }


void substraction()
{
        float  firstNumber, secondNumber, total;
    cout<<"\nWelcome to the SUBSTRACTION calculator who will substract 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
    cout<<"  First Number:";
    cin>> firstNumber;
    cout<<"        -     \n";
    cout<<" Second Number:";
    cin>> secondNumber;
    cout<<"\n\n\n";
    cout<<"Awnsser:";
    total = firstNumber - secondNumber;
    cout<<"\n"<< firstNumber <<" - "<< secondNumber << " = " << total ;
    }
void multiplication()
{
        float  firstNumber, secondNumber, total;
    cout<<"\nWelcome to the MULTIPLICATION calculator who will multiply 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
    cout<<"  First Number:";
    cin>> firstNumber;
    cout<<"        x     \n";
    cout<<" Second Number:";
    cin>> secondNumber;
    cout<<"\n\n\n";
    cout<<"Awnsser:";
    total = firstNumber * secondNumber;
    cout<<"\n"<< firstNumber <<" x "<< secondNumber << " = " << total ;

}
void divide()
{
        float  firstNumber, secondNumber, total;
    cout<<"\n   Welcome to the DIVISION calculator who will divide 2 numbers of your choice.\n\n\n\n\n\n\n\n\n\n\n\n"<<endl;
    cout<<"  First Number:";
    cin>> firstNumber;
    cout<<"        /     \n";
    cout<<" Second Number:";
    cin>> secondNumber;
    cout<<"\n\n\n";
    cout<<"Awnsser:";
    total = firstNumber / secondNumber;
    cout<<"\n"<< firstNumber <<" / "<< secondNumber << " = " << total ;

}

int main()
{

   string restart = "y";

   do
   {
   int choseThePath;

cout<<"chose what you whould like to do :)"<<endl;
cout<<"1. Addition"<<endl;
cout<<"2. Substraction"<<endl;
cout<<"3. Division"<<endl;
cout<<"4. Multiplication"<<endl;
cout<<"\n and you chose :";
cin>> choseThePath;
//addition path :D
if ( choseThePath == 1)
    {
        //dont bother this is useles in script lol its copy paste material was bored and wondering how people did stationary stuf if you know hit me up :)
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[           ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||         ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||       ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||      ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||     ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||    ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||   ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||  ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        Sleep(900);
            addition();
    }
//substraction path
if ( choseThePath == 2)
    {
        //dont bother this is useles in script lol was bored :)
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[           ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||         ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||       ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||      ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||     ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||    ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||   ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||  ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        Sleep(900);


            substraction();
    }
    //division path
    if( choseThePath == 3 )
    {
        //dont bother this is useles in script lol was bored :)
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[           ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||         ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||       ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||      ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||     ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||    ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||   ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||  ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        Sleep(900);

        divide();
    }
//multiplication path
if ( choseThePath == 4  )
    {
        //dont bother this is useles in script lol was bored :)
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[           ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||         ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||       ]";
        Sleep (500);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||      ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||     ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||    ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[||||||||   ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||  ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||| ]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[|||||||||||]";
        Sleep (100);
        cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n[LOADING DONE]\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";
        Sleep(900);
            multiplication();

    }

cout<<"\n\nwould you like to reset calcularor? (y/n):";
cin>>restart;
cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n";

   }while ( restart =="y" );

}
sawm
 
Posts: 8
Joined: Fri Aug 28, 2009 3:24 pm

Re: Project 1

Postby tommy on Wed Sep 02, 2009 2:15 pm

here is my attempt, first i have been looking at other peoples and they are alot better than mine. i still don't get 'when' to use the different things like: switch ect....


Code: Select all
#include <iostream>
using namespace std;

int main()
{
   int first; //first number chose.
   int second; //second number chose.
   char oppps; //operator chose.
   int answer; //answer at end.
    char exit; //wether you want to exit or not.:)

   cout << "welcome to our basic calculator\n"; //message.
   cout << "please enter a number\n"; //message .
   cin >> first; //first number entered and stored in this for further use.
   
   
      
       cout << "please enter a second number which you would like to +,-,/ or * \n"; // mesage.
      cin >> second; // stored second number within this for further use.

      cout << "please enter a operator e.g:  +, -, *, / \n"; //message about operator.
       cin >> oppps;
                       
                       
                       if(oppps == '+') {
         cout << first;
            cout << "+";
            cout << second;
            cout << "=";
            cout << first+second;
                  }else
         
         
         if(oppps == '-')   {
         cout << first;
            cout << "-";
            cout << second;
            cout << "=";
            cout << first-second;
       }else
           
          if(oppps == '*') {   
         cout << first;
            cout << "*";
            cout << second;
            cout << "=";
            cout << first*second;
        }else
           
            if(oppps == '/') {   
         cout << first;
            cout << " / ";
            cout << second;
            cout << " = ";
            cout << first/second;
         cout << " and the remainder would be "; cout << first%second;
         }else{
            cout << "invalid sign";
            }
 
   
      cout << "\n would you like to continue or leave? \n"; //message
      cout << "\n press 'x' to stay and anything else to leave :) \n"; //message
      cin >> exit;
     
      if (exit == 'x') {
               main();
               } else {
                      return 0;
                      }   
  }
tommy
 
Posts: 1
Joined: Wed Sep 02, 2009 12:21 pm

PreviousNext

Return to Projects

Who is online

Users browsing this forum: No registered users and 0 guests