• Some users have recently had their accounts hijacked. It seems that the now defunct EVGA forums might have compromised your password there and seems many are using the same PW here. We would suggest you UPDATE YOUR PASSWORD and TURN ON 2FA for your account here to further secure it. None of the compromised accounts had 2FA turned on.
    Once you have enabled 2FA, your account will be updated soon to show a badge, letting other members know that you use 2FA to protect your account. This should be beneficial for everyone that uses FSFT.

C++ Midterm... HELP!

Look at the times on the posts. Yeah, you're right, I initially wanted someone to just do it for me. Then go back to every single one of those links you posted. Nobody did it for me. Hence why I've been in this thread working out the code myself and asking for input.

I'm basically done with it now, I'm just not sure how to do do/while statements inside of other ones, inside of other ones, inside of other ones, etc. I'm not even sure if that's possible or if that's what's being asked of me is the thing.

actually, it looks like you got quite a bit of help and you'd post back and forth the little tidbits you found here and there. you could have gotten help without cheating, but you chose not to.

And I think it says something about your social life that you went out and found all those.

maybe it does. but i don't miss the 5 whole minutes it took on google for me to look it up, whereas you will be unhappy in a few days because of your failing this assignment. additionally, if google's cache picks up soon and i find some of your assignment's patterns posted in an assignment on some professor's site, you can bet he/she is going to be getting an email courtesy of a mighty pissed grad student at another university.
 
1) There is nothing wrong asking for help on a assignment (even if it was for his grade)

i agree. it's the manner he chose to do it.

2) So we all assumed he didn't know where to start (even if it was not what he was asking), amazing how everyone thought of it like that but you jumped at him thinking it was to ask for an answer. We clarified what it says for him about what he is to do, and gave him nothing else. Except Lmaulle (which someone pointed out)

it was a bad assumption on your part. the rules of the forum are not to assist someone who does exactly what he did. you chose to.
3) It was about as bad a response as your first one was.

oddly enough, i was right. go figure.
You were angry when other got by because of someone else's help? I could care less in my class if the jock went to someone else and they helped walked him through it, I cared very much if I was Teamed with him and had to do all the work (which I had to do 90% through school).

Even if the do pass, in the end it will hurt them badly. Trust me, nothing funnier then going out to the real world and watching them fail. Just like one of my former class mates (who I know didn't ever do his work) has a major in CS and works at McDonalds.

yes, i've seen those individuals as well. it's not funny, it's sad. they wasted fortunes wasting time in school. all they needed to do was fail an assignment or two and wake up. instead, they passed classes they didn't deserve to pass. now they are miserable. you didn't do him any favors.

again, it isn't that he came to ask for help. if he did that, it would be fine. he came to ask for answers, and you humored him.
 
You're right, I got help from multiple sources, yet put it all together myself.

All I'm asking is if there is a way to accept both Y and y as valid inputs for the program looping because if the user inputs 'y' it loops but if they input 'Y' it won't.

We were taught to use something like 'y'||"Y" but that didn't work.
 
First off, you assumed I would do work for someone else. I never did he failed because he didn't do his work (let other who were his friends do it). Second being a stickler for the rules never helps anyone. The rules of the forum state not to give him answers. Nothing about prodding him into doing it himself. Getting someone to learn is just as helpful as letting them fail. I was not the only one that tried to push him into getting the project started and what he should look at doing. Read the others on this forum, and read the other forums he posted at. One of the first posts berated him for not knowing what to do. But he did give him helpful insight on where he should start.

So we can bicker back and forth all night. I disagree with the way you want to approach by letting the fail and offer no help at all. I prefer to help get him pointed in the right direction and let him take it from there. If he chose not to do anything further, then I would have left it at that and done nothing for him. But if he wants to go further I will help him along the way (not giving answers but suggestions at what he look at).

at to CwilHelm: look at what || links together, find out what it can do and then think of the expression that would get around that.
 
it doesn't take any hard work at all to take answers from other places and pull them together yourself.

it's obvious that you haven't even been attending class because you don't even know how operator || works.

here's my hint for your problem to show i'm not heartless, just angry in the way you chose to ask for help:

'y' || 'Y' == true.

'y' == 'y' == true.

'Y' == 'Y' == false.

if you can look in your book or google it, you'll find that what you want to do is very easy. for God's sakes, do your own work for at least SOME of the assignment.
 
First off, you assumed I would do work for someone else. I never did he failed because he didn't do his work (let other who were his friends do it). Second being a stickler for the rules never helps anyone. The rules of the forum state not to give him answers. Nothing about prodding him into doing it himself. Getting someone to learn is just as helpful as letting them fail. I was not the only one that tried to push him into getting the project started and what he should look at doing. Read the others on this forum, and read the other forums he posted at. One of the first posts berated him for not knowing what to do. But he did give him helpful insight on where he should start.

So we can bicker back and forth all night. I disagree with the way you want to approach by letting the fail and offer no help at all. I prefer to help get him pointed in the right direction and let him take it from there. If he chose not to do anything further, then I would have left it at that and done nothing for him. But if he wants to go further I will help him along the way (not giving answers but suggestions at what he look at).

at to CwilHelm: look at what || links together, find out what it can do and then think of the expression that would get around that.

i don't want him to fail. i want him to do the work on his own. help from others is fine. free answers are not. if he doesn't understand what a question is asking him, it is best policy for him to explain what he does know and we can give help connecting the dors to what he doesn't understand... not interpreting it for him. it is, after all, a midterm. don't you remember the point of midterms?

edit: my point is this.. it was wrong of you to jump right in and being helping under such posts that he was making. it is no big deal, you didn't know any better. however, HE did. he shouldn't have done it, and we ought to help him as much as we can... but that doesn't mean giving him any answers. when the dots connect because he put some work in and asked proper questions, we'll know we've done it right. otherwise, his postings were useless and so were ours, even if he passes the assignment.
 
the function I posted you could easily find on google. but the assignemnt said using a string so he can't use my function. was just showing one technique to do it.
 
Well here is what I've come up with so far to include both of these in the same program.

Is there an easier way to do this? I can't get it to run.

Basically I wrote it trying to have a do/while inside of a do/while.

I had it running before and it was capable of performing both functions, except when it finished and I asked if it wanted to be done again, it would start from the same process initially selected instead of going back and asking D2B or B2D again.

When I try to run this, it tells me the the end of the program is found before the bracket is matched. Ugh...

Code:
/*
Craig Wilhelm
18.October.2008
Midterm Assignment
CISP301, TTH, 19:00

18.October.2008
----------
Syntax Created, Modified, Rewritten,
Re-rewritten, Tested, Stared At, Checked,
Tested, Rewritten, Stared At, Finished
*/

#include <iostream>
#include <string>
using namespace std;

string DtoB(int Decimal);

string DtoB(int Decimal)
{
int steps[] = {128, 64, 32, 16, 8, 4, 2, 1};
string binary;

if(Decimal > 0)
{
int stepLen = sizeof(steps) / sizeof(int);
for(int x = 0; x < stepLen; x++)
{
if(Decimal >= steps[x])
{
Decimal -= steps[x];
binary += "1";
}
else
binary += "0";
}
}
else
binary = "0";

return binary;
}

/* DP. What Say You? */

/* DELETE THIS IF YOU HAVE PROBLEMS */
void BaseGen(int Base[], int Size)
{
Base[0]=1;		// the first element is always 1
int Index=1;	// start with the second value
while(Index<Size)	// must load all Base elements
	{
	Base[Index]=Base[Index-1]*2;	// left = right *2
	Index=Index+1;		// Bump the Index  
	}
	return ;
}
int BtoD(string Binary)
{ 
	unsigned int Index=1;  	//loop control variable 
  	Index=0;		// Initialize to zero
	int Dv=0; 		//Dv is the decimal value for the binary number in Binary
	int Base[8];		//  Base array to store binary base values
	BaseGen(Base,8);			// Load Base
	while(Index<Binary.size()) 		// loop to check all bits
	{
	if (Binary[Index]=='1')  		// if the value is 1
	Dv=Dv+Base[Binary.size()-1-Index];  	// add the corresponding base value to Dv
		Index=Index+1; 		// Bump the loop control variable
	}
		return Dv; 			// Return the decimal value
}
/* END DELETE */

int main()
{

	char repeat;
	int abc;
	string Bin;

	cout << "Press 1 for Decimal to Binary or 2 for Binary to Decimal: ";
	cin >> abc;

	switch(abc){
	
	do {
		case 1:
		do
			{
				{
					cout << "Enter an integer no larger than 255: ";
					int Decimal;
					cin >> Decimal;
					if (Decimal > 255)
						{
						cout << "Please follow instructions." << endl;
						}
					else
						{
						cout << "Binary: " << DtoB(Decimal) << endl;
						}
				}

					cout << "Again? y/n: ";
					cin >> repeat;
			
		case 2:
		do
			{
				{
					cout << " Please type any valid Binary Number of eight or less bits" << endl;
					int Decimal2;
					cin >> Bin;
					Decimal2=BtoD(Bin);
					cout << " The decimal value of " << Bin << " is = " <<Decimal2 << endl;
				}

		cout << "Again? y/n: ";
		cin >> repeat;

	while (repeat == 'y');
	{
	system("PAUSE");
	return(0);
			}
			}	
/* End DP. What Say You? */
 
Before this code, this is basically what I had it doing:

Press 1 for Decimal to Binary, Press 2 for Binary to Decimal:
1/2
Perform D2B or B2D, based on input
Again? Y/N
If yes, it would return to either B2D or D2B, depending on first input

This code I just posted is my attempt to make the program go back to the beginning if they enter yes, to where it will say 1 or 2 for d2b or b2d again instead of just assuming they want to do the same. I want to make it so that they can choose to either do D2B or B2D again, so they wouldn't have to restart the program or something.
 
Well that's that. He never specifies he wants any type of error detection, so other than decimal numbers greater than 255, it will not be included. This is the final code for both D2B and B2D. Any suggestions are welcome but this seems to work just fine.

Code:
/*

Craig Wilhelm
18.October.2008
Midterm Assignment
CISP301, TTH, 19:00

18.October.2008
---------------
Initial Scripts

*/

#include <iostream>
#include <string>
using namespace std;

/* CONVERT DECIMAL TO BINARY */

string DtoB(int Decimal);

string DtoB(int Decimal)
{
	int steps[] = {128, 64, 32, 16, 8, 4, 2, 1};
	string binary;

		if(Decimal > 0)
		{
			int stepLen = sizeof(steps) / sizeof(int);
			for(int x = 0; x < stepLen; x++)
			{
			if(Decimal >= steps[x])
				{
				Decimal -= steps[x];
				binary += "1";
				}
			else
				binary += "0";
			}
		}
	else
		binary = "0";

return binary;
}
/* END DECIMAL TO BINARY CONVERSION*/

/* CONVERT BINARY TO DECIMAL */

void BaseGen(int Base[], int Size)
{
Base[0]=1;
int Index=1;
while(Index<Size)
	{
	Base[Index]=Base[Index-1]*2;
	Index=Index+1;
	}
	return ;
}

int BtoD(string Binary)

{ 
	unsigned int Index=1;
  	Index=0;
	int Dv=0;
	int Base[8];
	BaseGen(Base,8);
	while(Index<Binary.size())
	{
		if (Binary[Index]=='1')
			Dv=Dv+Base[Binary.size()-1-Index];
			Index=Index+1;
	}
		return Dv;
}

/* END BINARY TO DECIMAL CONVERSION */

/* BEGIN DP. WHAT SAY YOU? */

int main()
{
	string Bin;	

		cout << "Please type any valid integer no larger than 255: " << endl;
		int Decimal;
		cin >> Decimal;

		if (Decimal > 255)
			{
			cout << "Game Over." << endl;
			system("PAUSE");
			return(0);
			}
		else
			{
			cout << "Binary: " << DtoB(Decimal) << endl;
			}
	
		cout << "Please type any valid binary number of eight or less bits: " << endl;
		int Decimal2;
		cin >> Bin;

		Decimal2=BtoD(Bin);
		cout << "Decimal: " << Decimal2 << endl;
		system("PAUSE");
	
	return(0);
}

/* END DP. WHAT SAY YOU? */
 
Back
Top