NOGDUS
February 24, 2018, 11:02:24 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Blogs Help Search Tags Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Script erros seeking for help lol  (Read 2672 times)
0 Members and 1 Guest are viewing this topic.
rickynl
Guest
« on: July 29, 2009, 06:42:48 PM »

Hey i made this Calculator that adds 2 numbers with a loop that keeps running if you want it too.... but i'm getting errors Since im a newbie i cant really figure out what i have to change to make it right lol
Code:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>


using namespace std;

int main()
{

char name, loop='Y';
float A, B, C;
  while ('Y'==loop||'y'==loop)
  {
          cout << "\nPlease Type in your name and hit enter\n\n";
   cin >> name;
   cin.ignore();
          cout << "\nHello " << name << " This program Adds two numbers to eachother\n\n";
   sleep (2);
          cout << "Please type in the first number and hit enter:\n\n";
   cin >> A;
   cin.ignore();
          cout << "\nPlease type in the second number and hit enter:\n\n";
   cin >> B;
   cin.ignore();
         cout << "\nPress enter to start calculating "<< A <<"+"<< B <<"\n\n";
         cout << "Preparing calculations........\n";
   sleep (1);
         cout << "Calculating Please wait........\n\n";
   C=A+B;
   sleep (3);

         cout << A << "+" << B << "=" << C <<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" ;
   sleep (2);
         cout << "Would you like to Calculate some more numbers (Y/N)??";
   cin >> loop;
   cin.ignore();
  }
           cout << "Thank you for using this marvelous (sarcasm) Calculator";
           cin.get();
return 0;
}
No errors Some weird loopage
Logged
RedSlash
Member
*

Respect: 10
Offline Offline

Posts: 50


« Reply #1 on: July 29, 2009, 07:40:58 PM »

For one thing, name should be a std::string, not a char. char only holds 1 character.
Logged
Richard Marks
202192397
Administrator
Member
*

Respect: 3425
Offline Offline

Posts: 1027


happy


« Reply #2 on: July 29, 2009, 11:14:12 PM »

This has been solved off-forum. thread locked.
Logged

Tags: calculator loop etc 
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!