Black Magic 15 Junior Poster

DEV-C++

Black Magic 15 Junior Poster

Hi, i was just wondering how i could do this,

Say if i made a char array, password,

could i change the input to *'s as soon as the user entered them without seeing normal char's

Thanks.

Black Magic 15 Junior Poster
#include <iostream>

using namespace std;

int main()
{
    char exit;
    
    cout << "Exit? Y / N " << endl;
    cin >> exit;
    
    if ( exit == 'Y' || exit == 'y' )
       { }
       
    if ( exit == 'N' || exit == 'n' )
        system("PAUSE>nul");
        
    else
    { }
    
}

I solved through trial and error, heres the code if you ever want to use it, thanks :)

I guess you could change

else
    { }

To

else
    cout << "Invalid Selection!" << endl;

Hope this helps.

Black Magic 15 Junior Poster
Black Magic 15 Junior Poster

I'm sorry but, i was wanting to do this by myself (the actual code) i was just really asking for what i should use. Thanks...

This wasn't even homework just problem from a page............

Black Magic 15 Junior Poster

The question doesn't say how many though :O

Black Magic 15 Junior Poster

I know this is solved now but, i see you've got

if (word[i] >= 'a' and word[i] <= 'z')

I thought the "and" opperator was "&&" ?

Black Magic 15 Junior Poster

Hi, i was looking on the practise question sticky and i came across this question,

Write a program that allows you to input students' scores and weights. The program should then calculate a weighted average and score based on the data inputted by the user. (Beginner)

I'm not going to ask you for the answer but i was wondering should i use a array to keep track of the multiple students?

Many thanks.

Black Magic 15 Junior Poster

so do you think if i tried i might be able to make a simple text based game?

Black Magic 15 Junior Poster

Thanks, i'm just really mucking around atm but im going to make somethings like Elliot.setAge(81); in a minute or two :)

Btw, can you tell me another alternative to system("PAUSE>nul");

Because pause nul gets rid of press any key to continue,

What other solutions can i use?

EDIT: Is this the right way to start a simple poker game?

class Cards
{
      public:
                  
      unsigned int Ace;
      unsigned int Two;
      unsigned int Three;
      unsigned int Four;
      unsigned int Five;
      unsigned int Six;
      unsigned int Seven;
      unsigned int Eight;
      unsigned int Nine;
      unsigned int Ten;
      unsigned int Jack;
      unsigned int Queen;
      unsigned int King;
    };
Black Magic 15 Junior Poster

Yeah, sorry about that.
I'm learning classes atm and my little brother is telling me what to do, kind of fun :).

#include <iostream>

using namespace std;

    class Cat
    {
          public:
                  
          unsigned int Age;
          unsigned int Weight;
          unsigned int Siblings;
          unsigned int Smoke;
          unsigned int TV;
          
          void Meow();
    };
    
int main()
{
    system("title Class Cat.");
    
    Cat Elliot;
    
    Elliot.Age      = 81;
    Elliot.Weight   = 132;
    Elliot.Siblings = 20;
    Elliot.Smoke    = 0; // 0 = False, 1+ = True.
    Elliot.TV       = 1; // 0 = False, 1+ = True.
    
    cout << "Elliot is a cat who is " << Elliot.Age << " years old.\n" << endl;
    cout << "Elliot weighs " << Elliot.Weight << "kg!\n" << endl;
    cout << "Elliot has " << Elliot.Siblings << " siblings!\n" << endl;
    
    if (Elliot.Smoke == 0)
       cout << "Elliot Does Not Smoke!\n" << endl;
    else
        cout << "Elliot Smokes!\n" << endl;
        
        if (Elliot.TV == 0)
       cout << "Elliot does not watch TV!\n" << endl;
    else
        cout << "Elliot watches TV!\n" << endl;
    
    system("PAUSE>nul");
}
Black Magic 15 Junior Poster

Ok.

Off Topic : Does any one have Msn-Messenger or another IM, so i can ask help through that please :)

Black Magic 15 Junior Poster

So is there not a way you can code it in?

Black Magic 15 Junior Poster

Hello,

I was wondering if you could change the program icon (it's usually a picture of c:\), and without making a gui progra, just a normal one if you get me?

Like you can change the title by; system("title This Is Your Title");

Help a.s.a.p please :).

~ Black Magic

Black Magic 15 Junior Poster

this is not a program i am building on, i am learning C++ and looking at sites trying to learn part by part, then trying to rewrite the program without looking at original to try to learn and remember, and thanks for help

Black Magic 15 Junior Poster

Help please, just made this little program, no errors but it does not write any text for me on Dev-C++.

#include <iostream>

using namespace std;

int main()
{
    system("title Array Program.");
    
    int myArray[5];
    int loop;
    
    for (loop = 0; loop > 5; loop++)
    {
        cout << "Value for myArray[" << loop <<"] : ";
        cin  >> myArray[loop];
    }
    
    for (loop = 0; loop > 5; loop++)
    
    cout << "#" << loop << " : " << myArray[loop] << endl;
    
    system("PAUSE>nul");
}

Please help?

Black Magic 15 Junior Poster

Yes only 1 mistake.

Black Magic 15 Junior Poster

Can you post some code, im a little rusty :)

Black Magic 15 Junior Poster

Hi, im just bored so was mucking around on Dev-C++ and then was wondering - how could i make it so my program said a random sentance, like if i defined loads, and it said one at random.

Could you help :).

Black Magic 15 Junior Poster

google sites dont usually help me, a website would help

Black Magic 15 Junior Poster

thanks, is there a website where i can get all things? like move, click,wait etc :)

Black Magic 15 Junior Poster

Hi, can you post some code how to move the mouse etc :) just i would like to experiment making programs like that, many thanks.

Black Magic 15 Junior Poster

error: 'struct std::istream' has no member named 'error'

Black Magic 15 Junior Poster

Sorry i meant quote,

Black Magic 15 Junior Poster

Hey, i saw this thread about some one needing homework help but it was solved so i made one and it's not real homework but i was wondering how i could do something if the user entered a letter eg "e".

#include <iostream>
using namespace std;

int main()
{
    int dollarAmmount;
    
    cout << "Enter A Dollar Ammount Between $0 & $100" << endl;
    
    cout << "$";
    cin >> dollarAmmount;
    
    if (dollarAmmount < 0)
    cout << "ERROR : Dollar Ammount Is To Low.";
    
    if (dollarAmmount > 100)
    cout << "ERROR : Dollar Ammount Is To High.";
    
    else
    cout << "Thanks.";
    
    system("PAUSE>nul");
}

Like.. to make it have a error like "ERROR : Input Is Not A Digit."

Black Magic 15 Junior Poster

Yeh, i agree remove that line, but even if you did, multiplication is read before addition, so no need for brackets, if i am correct?

Black Magic 15 Junior Poster

Hello,

This thread is not about you solving my homework, infact i only go to secondry school so don't get it, this sounds weird but can you give me some homework examples brcause i want to learn C++ and i think it may help, please reply a.s.a.p :).

~ Black Magic.