mrnutty 761 Senior Poster

1st tooo much common sense comment :

second ;

while (num != 0)
{
digit= num%=10;  // you are setting digit to the last number of 10 each time this loop runs. So you end up with a 1 digit number
num/=10;
}

To reverse the number first find out its degree, i.e 1 has a degree
of 0, 10 has a degree of 1, 100 has 2, 1000 has 3 ....

The use the mod operator to extract the last number of
the value passed from the parameter, and multiply it with
the total degree. Then divide degree by 10, and again
add the num%10 * degree .. and repeat, until !deg

mrnutty 761 Senior Poster

It alls here :

{
			switch (choice)
			{
			case 'a':
			case 'A': cout << "You are accelerating the car. ";
				cout << Accelerate(first) << endl;
				break;
			case 'b':
			case 'B': cout << "You have choosen to push the brake.";
				cout << Brake(first) << endl;
				break;
			}
		}while (toupper(choice) != 'C');

You need to use the member to call the function Accelerate,and
brake, like so first.Accelerate(...), first.brake(...), and also you
are missing a bracket.

//Process the user's menu selection
		{ <--//either remove this or
}   
                    } //<-- or add this.
		}while (toupper(choice) != 'C');
mrnutty 761 Senior Poster

vector<vector<char>> vset; //that should be an error because of the
confusion of the stream operator >>. Need space between them.

mrnutty 761 Senior Poster

hey FirstPerson, where did you found the algorithm? Is it proven and works on any other number?

Regards,
Nick

which 1?

mrnutty 761 Senior Poster

If not defined the compiler create a :

default constructor like so someClass() { }, that does nothing
default destructor like so ~someClass() {}, that does nothing
default assignment operator
default copy constructor
default address operator

mrnutty 761 Senior Poster

how about you give it a start, from the top. Follow each step, and
see where you get.

mrnutty 761 Senior Poster

Ok, let me know how it goes

mrnutty 761 Senior Poster

Just don't use Hungarian. I use Camel naming convention like so ,

float PlayerLife

mrnutty 761 Senior Poster

What do you mean by floor and ceiling? The function?

mrnutty 761 Senior Poster

I mean ask the user for input, and then have a counter variable
that determines how many seats the user has gotten. If none
then search from Array[0] to Array[MAX], until the counter has reached
the needed number of seats.

mrnutty 761 Senior Poster

create a vectors of char*, then in a for loop, have char* pointing
to a different vectors.

mrnutty 761 Senior Poster

Just 1 function applied 3 times

mrnutty 761 Senior Poster

rand() will give you random number from 0 to 0x7fff.
You can manipulate rand the give you what you want. To get random
number every time you will need to seed the random number
generator.

If you can't use random number then try something like this :
1) Get user input for how many seats
2) From 0 till seatRecivedCounter reaches seat, search the
array for empty seat.

That would be sequential.

mrnutty 761 Senior Poster

1) Ask user if he wants a seat, if so then
2) Check if there are seats to fill
3) If full, then give an error, else
4) get any random seat from the list of unfilled seat array

mrnutty 761 Senior Poster

string have insert and replace

mrnutty 761 Senior Poster

Here is a comment on the comments (just a few):

input qty // get input from user, by creating a new variable and cin >>variable

while qty > 0 //start a loop, with the conditional statement being while qty > 0

input size// ask user to input, same as step 1


//You need to create a calculareScrap function that does what it
//needs to do.
call Calculate Scrap using 10 to get scrap 10, qty needed for 10

call Calculate Scrap using 25 to get scrap 25, qty needed for 25

call Calculate Scrap using 40 to get scrap 40, qty needed for 40

mrnutty 761 Senior Poster

google opengl loading texture tutorial. You will find how to load
in image files.

mrnutty 761 Senior Poster

If maxNum is multiple of 100 the I guess you can do this:

if(maxNum%100==0)
maxNum %=99

max*=19;

mrnutty 761 Senior Poster

Oh wait My bad.

mrnutty 761 Senior Poster
ike this : 3,13,23,33,43,53,63,73,83,93 ?

yes like this.

Looking at this you don't even need a for loop.

Look at the pattern : 3,13,23,33,43,53,63,73,83,93,103,113,123,133...

It seems that there is 10 3's in every 100;

so ask user for max num;

set maxNum %= 100;

multiply maxNum by 10; and you have your answer.

mrnutty 761 Senior Poster

to put code tags, do this :

code */code , except delete * and leave no space in between.

mrnutty 761 Senior Poster

what part of that are you having problem with? Starting it?

You will learn a lot more if you give it a try then see the solution,
then just study the solution.

mrnutty 761 Senior Poster

"(1) how to capture number of occurrences of 3 between 1 to 100? "

Like this : 3,13,23,33,43,54,63,73,83,93 ?

mrnutty 761 Senior Poster

What do you mean. Something like this :

static int Array[5] = {1,2,3,4,5};

mrnutty 761 Senior Poster

Simply use "srand()" at the start of the program.

srand() takes an argument.

mrnutty 761 Senior Poster

Samlem is right, forget about strcpy, go with the more same
std::string.

mrnutty 761 Senior Poster

"Okay so if I use new then I delete Thanks"

only if its not placement new,in some cases.

mrnutty 761 Senior Poster

also in c++, its #include< fstream> and not fstream.h

mrnutty 761 Senior Poster

On the other hand, if you use new to allocate memory for the array
then you should use delete [] array, syntax. And set the other pointers
associated with the array to null.

Also Why are you doing this :

double *pd = new (a + 5) double;

when a is an int array.

Your trying to destroy your compiler aren't you?
You should not mix up data like that.

mrnutty 761 Senior Poster

use seekg to set the position of the pointer to the beginning after
its been read.

http://www.cplusplus.com/reference/iostream/istream/seekg/

mrnutty 761 Senior Poster

"Why not just str1 = str2;"

Just an example of the logic involved to create strcpy. Its there
so he could use a similar one for which he needs, need it not to
be a char*.

mrnutty 761 Senior Poster

something like this(not tested) :

void genRan(int array[], int sz)
{ 
   int *tmp = new int[sz];
   for(int i = 0; i < sz; i++)
         tmp[i] = i;

    //pick randome index from tmp, check if its a unique index
    // if so then populate array with the content from tmp.
  
   delete [] tmp;
}
mrnutty 761 Senior Poster

just make your own strcpy. Its not hard

//copy string 2 into string 1
 bool stringCopy(std::string* str1, std::string* str2)
{
   if(!str2[0]) return false;

  for(int i = 0; i < str2.size; i++)
       str1[i] = str2[i]; 

  return true;
}
mrnutty 761 Senior Poster

Create an array;
From 'i' to 'SIZE' store 'i' into array.
shuffle array;

extract info from array into new one, without the same index
repeating.

DangerDev commented: nice solution +2
mrnutty 761 Senior Poster

You don't need a copy constructor for that. Only if you are using
dynamic memory, then you will need a copy constructor. The
std::string is it self dynamic and thus you don't have to keep
track of heap memory for it, the stl does it for you.

mrnutty 761 Senior Poster

Its only a variable name.

ofstream oFile; //oFile is a variable name
ifstream iFile; //iFile is a variable name
mrnutty 761 Senior Poster

You can't use " while(oFile.getline(std::string)) " it that way,

I mean to declare a variable std::string data; and use the variable
data inside of getline like so :

ifstream iFile("temp.txt");
	//error check
	
	string data;

	getline(iFile,data);

	cout<<s;
mrnutty 761 Senior Poster

No, a char can only hold 1 character. The code reads
each character in the file, and prints out the character.

You will need to use the std::string instead of char c.
And instead of using iFile.get(c), you will need to use
iFile.getLine(...) to read a whole line;

Or you can do an alternative. You can use the code I gave you.
Instead out only printing out each character in the while loop,
you can use a string variable to add each character to the string.

mrnutty 761 Senior Poster

You need to define a base class, in your case the BankAccount
class, methods (i.e functions) to be a virtual only if you will
define a same named functions in your derived class.

class A { ...  virtual int prnt(){...} };
class B : public A { ... int prnt(){...} };

Notice that prnt is a virtual function because that class is being
used as a base class. And the derived class also define the same
named function.

so if your base class (BankAccount) has a function of the same name as your derived class then make it virtual.

mrnutty 761 Senior Poster

Here is an example :

#include<iostream>
#include<fstream>

using namespace std;

int main()
{ 
	char c;

	ifstream oFile("temp.txt"); //open a file name temp. Needs to be in the same directory as the file

	if(!oFile) //check for failure, i.e does the file exist?
	{
		cout<<"Failed to open\n";
		exit(1); //exit failure 
	}
	while(oFile.get(c)) //while there is stuff to read
       {
           cout<<c; //print that stuff
       }
}
mrnutty 761 Senior Poster

use protected instead of private with those variables. i.e change the keyword private to protected.

mrnutty 761 Senior Poster

Do you know how to read in a file? I want to give you the code, but I the law says I can :(
Although I can help you get there.

mrnutty 761 Senior Poster

if you don't want to get the user's input as a string you can
do the following (not tested) :

int num = 0;
 cout<<"Number please : ";
 cin >> num;

 while(!cin)//if input fails
{
   cin.clear();
   while(cin.get() != '\n')
     continue;
  cout<<"\nInvalid Input\n";
  cout<<"Try again : ";
  cin >> num;
}
mrnutty 761 Senior Poster

If your using c++ , the command cout<<"\a"; makes a beep. You can
be creative.

If you are using windows, you can use beep(...), and adjust
the frequency and the length of the tone. You can be creative.

mrnutty 761 Senior Poster

You can encrypt the text file just as you would encrypt a string.

1) Use a string to read in all data inside the ifstream
2) Use that string to encrypt it self , for example you can use
key number to encrypt like so :

cout<<"Enter a key number : ";
int num;
cin >> num;

for(int i = 0; i < stringData.size(); i++) //stringData already contains all information from txt file
{
     stringData[i] += key;
}

3) To decrypt the data, you can just reverse the process, i.e
stringData -= key.

mrnutty 761 Senior Poster

Why would you want to do that?

how about cout the expression manually?

mrnutty 761 Senior Poster

use the std::sort algo. you will need to give it your compare function
which should compare the x first then the y.

example :

#include<iostream>
#include<vector>
#include<algorithm>

using std::vector;
using std::cout;
using std::cin;
using std::endl;


int main()
{  

	vector< vector<float> > vec2d(2,vector<float>(2,0));

	for(int i =0; i < vec2d.size(); i++)
	{
		cout<<"Enter "<<vec2d[i].size()<<" numbers for col "<<i<<"\n";

		for(int j = 0; j < vec2d[i].size(); j++)
		{

			cin >> vec2d[i][j];			
		}

	}

	std::sort(vec2d.begin(),vec2d.end());
	
	for(int i =0; i < vec2d.size(); i++)
	{
 
		for(int j = 0; j < vec2d[i].size(); j++)
		{

			cout<<vec2d[i][j]<<" ";
		}
		
		cout<<"\n";
	}		
}

You will have to adjust it though.

mrnutty 761 Senior Poster

I would if I was at school right now, but sorry I am in my summer
vacation :)

mrnutty 761 Senior Poster

which language do you want to achieve this?

mrnutty 761 Senior Poster

This is how to do inheritance`:

class BankAccount { ... } //base class
class Savings : pubilc BankAccount { ... } //saving derives from base
class Checking : public BankAccount { ... } //checking derives from base
class CD : public BankAccount { ...}

The interface of BankAccount class would be public , so the outside
world would get to use them.

Now you should implement, the needed functions in checkings,
savings and CD class. The needed functions are described in your
notes in the first post.

Continue from this , let me know how it goes.