You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!

Author Search Results: 'FallingTears'

We found 252 matches.


<< < > >>

Viewing 1-30 of 252 matches. 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

1.

None

Topic: Good programmer = Bad mathematician

Posted: 11/13/09 07:30 PM

Forum: Programming

I have done research and I've come to find that those who major in Computer Science are required to maintain an engineering standing, which requires a few math courses. For example, take a look at the University of Kentucky's program in Computer Science:

MA 113 Calculus I ........................................
........................................
.... 4
MA 114 Calculus II ........................................
........................................
... 4
CS 100 The Computer Science Profession ........................................
.... 1
CS 115 Introduction to Computer Programming ...................................... 3
CS 215 Introduction to Program Design,
Abstraction, and Problem Solving ........................................
................ 4

From Oxford University in England:

* A-levels: AAA
* Advanced Highers: AA/AAB
* IB: 39 points, including core points
* or any other equivalent

Candidates are expected to have Mathematics to A-level (A grade), Advanced Higher (A grade), or Higher Level in the IB (score 7) or another equivalent. Another Science or Further Mathematics would also be highly recommended.

So, to put it quite bluntly, I believe that Math is a major part of computer programming whether directly or indirectly.


2.

None

Topic: C++ Tutorial

Posted: 10/29/09 11:25 AM

Forum: Programming

Honestly,

That's not the best C++ tutorial I've seen. And actually, two books by Diana Zakk about C++ are the best C++ resources that I've seen in my life for people who are starting to learn C++.


3.

None

Topic: Ajax Frameworks: Which is the best?

Posted: 10/26/09 11:03 AM

Forum: Programming

At 10/22/09 03:10 AM, Drakim wrote: Personally, I think Ajax frameworks are silly. You can do Ajax with like, 4 lines of code, and the interface that the Ajax frameworks are rarely any shorter. It feels too much like pushing a button to summon a robot to push a button for you.

Where the hell are you from? You can't do AJAX with like "4 lines of code," that's the biggest amount of BS that I've seen in my life. Literally dude, you look like a complete stupid ass when you talk about things that you have no knowledge of. And AJAX frameworks have way many more lines of code than 4. I have a framework that consists of about 400 javascript files not including the css files that add a User Interface to the AJAX framework.

Man, that's so irritating ....


4.

None

Topic: Ajax Frameworks: Which is the best?

Posted: 10/21/09 10:59 PM

Forum: Programming

jQuery is pretty neat. What are some things jQuery can do?


5.

None

Topic: Ajax Frameworks: Which is the best?

Posted: 10/16/09 07:23 PM

Forum: Programming

Anyone else have anything to say about AJAX?


6.

Elated

Topic: Ajax Frameworks: Which is the best?

Posted: 10/07/09 01:31 AM

Forum: Programming

Which AJAX Framework is the best? Currently, I'm extremely impressed with EXT. In fact, I've recently transferred EXT to my personal website to be used in the production of my website. I really like many of the layouts that can be created using the library. However, one of my questions is ...

How much of the site should be designed with AJAX? How much should be designed with HTML, CSS, or PHP (or other scripting language)?


7.

None

Topic: Php: Creating A Blog

Posted: 09/28/09 12:58 AM

Forum: Programming

WOW! This has helped me tons!!!!!!! Muchos gracias, mi amigo!


8.

Mad as Hell

Topic: Sql Help

Posted: 09/12/09 02:52 AM

Forum: Programming

I'm having a problem making my queries work properly. I'm using Microsoft Access. First, here's a look at my tables:

Customers:

customerID
customerName
customerAddress
customerCredit
customerBalance

Items:

itemID
itemName
itemPrice
itemQuantity

Orders:

orderID
itemID
repID
customerID

orderQuantity
orderDate

Reps:

repID
repFirstName
repLastName

Okay, this is what I'm trying to do. I'm attempting to calculate the inventory after orders are processed. I don't care if it's just a query, or if it's a new table, whether it's done by INNER JOIN or by a nested query ... I just need help figuring out how to make it calculate the remaining inventory. Here is my SQL:

SELECT item.itemID, item.itemName, item.itemQuantity AS Quantity_Before_Sales, orders.orderQuantity AS Number_Sold, Sum(item.itemQuantity-orders.orderQuantity) AS Quantity_After_Sales
FROM item INNER JOIN orders ON item.itemID=orders.itemID
GROUP BY item.itemID, item.itemName, item.itemQuantity, orders.orderQuantity;

Here is the results, the results are not what I'm looking for. The mistakes are outlined after the XML section (exported as an XML, because it was easier to copy and paste to the BBS):

<?xml version="1.0" encoding="UTF-8" ?> 
- <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Inventory.xsd" generated="2009-09-12T01:48:49">
- <Inventory>
  <itemID>CT120</itemID> 
  <itemName>Scissors</itemName> 
  <Quantity_Before_Sales>5</Quantity_Before_Sales> 
  <Number_Sold>3</Number_Sold> 
  <Quantity_After_Sales>2</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT121</itemID> 
  <itemName>Dell Computer</itemName> 
  <Quantity_Before_Sales>12</Quantity_Before_Sales> 
  <Number_Sold>5</Number_Sold> 
  <Quantity_After_Sales>7</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT122</itemID> 
  <itemName>Couch</itemName> 
  <Quantity_Before_Sales>3</Quantity_Before_Sales> 
  <Number_Sold>20</Number_Sold> 
  <Quantity_After_Sales>-17</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT122</itemID> 
  <itemName>Couch</itemName> 
  <Quantity_Before_Sales>3</Quantity_Before_Sales> 
  <Number_Sold>3</Number_Sold> 
  <Quantity_After_Sales>0</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT123</itemID> 
  <itemName>DSL Modem</itemName> 
  <Quantity_Before_Sales>50</Quantity_Before_Sales> 
  <Number_Sold>3</Number_Sold> 
  <Quantity_After_Sales>47</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT123</itemID> 
  <itemName>DSL Modem</itemName> 
  <Quantity_Before_Sales>50</Quantity_Before_Sales> 
  <Number_Sold>4</Number_Sold> 
  <Quantity_After_Sales>46</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT124</itemID> 
  <itemName>Speakers</itemName> 
  <Quantity_Before_Sales>12</Quantity_Before_Sales> 
  <Number_Sold>17</Number_Sold> 
  <Quantity_After_Sales>-5</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT125</itemID> 
  <itemName>Potatoes</itemName> 
  <Quantity_Before_Sales>200</Quantity_Before_Sales> 
  <Number_Sold>13</Number_Sold> 
  <Quantity_After_Sales>187</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT126</itemID> 
  <itemName>Picture Frames</itemName> 
  <Quantity_Before_Sales>40</Quantity_Before_Sales> 
  <Number_Sold>2</Number_Sold> 
  <Quantity_After_Sales>38</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT127</itemID> 
  <itemName>Window Shades</itemName> 
  <Quantity_Before_Sales>33</Quantity_Before_Sales> 
  <Number_Sold>1</Number_Sold> 
  <Quantity_After_Sales>32</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT128</itemID> 
  <itemName>WebCam</itemName> 
  <Quantity_Before_Sales>7</Quantity_Before_Sales> 
  <Number_Sold>60</Number_Sold> 
  <Quantity_After_Sales>-53</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT129</itemID> 
  <itemName>Paint</itemName> 
  <Quantity_Before_Sales>74</Quantity_Before_Sales> 
  <Number_Sold>12</Number_Sold> 
  <Quantity_After_Sales>62</Quantity_After_Sales> 
  </Inventory>
- <Inventory>
  <itemID>CT130</itemID> 
  <itemName>Teddy Bear</itemName> 
  <Quantity_Before_Sales>40</Quantity_Before_Sales> 
  <Number_Sold>50</Number_Sold> 
  <Quantity_After_Sales>-10</Quantity_After_Sales> 
  </Inventory>
  </dataroot>

Every place that contains two listings for the same item demonstrates the problem with my inventory SQL code. As far as I can tell, only two items have more than one listing, all the others have a single listing. So, I need to compensate for all items that have more than one listing as well as the items that have a single listing, because I want to show all of these in the same query .... then make a report of it.


9.

None

Topic: Serious Php Problems

Posted: 09/06/09 05:44 PM

Forum: Programming

I accidently downloaded the Thread Save VC9 edition, instead of the thread safe VC6 edition of php (which is created for apache instead of IIS).


10.

None

Topic: Serious Php Problems

Posted: 09/04/09 01:08 AM

Forum: Programming

I get the same results from a totally default php.ini file .... I'm thinking about replacing php5 with php6 or something


11.

None

Topic: Serious Php Problems

Posted: 09/04/09 12:46 AM

Forum: Programming

By the way, when I make a bad enough error like

<?php

echo phpinfo(

?>

Nothing shows up, not even an error.

However, if I do something like this:

<?php

echo phpinfo()

?>

My PHP info is printed and no error about my semi colon missing is displayed. To prove my problem I also tried this:

<?php

echo 5+5

?>

I get the output of 10, without the semi-colon.  I need my error's to work and to show up.  Is this a bug with PHP 5.3.0?

12.

None

Topic: Serious Php Problems

Posted: 09/04/09 12:35 AM

Forum: Programming

System Information:

Apache 2.2
MySQL 5.1.37
phpMyAdmin 2.11.9.5
PHP 5.3.0

I have read, re-read, double re-read, and asked my wife to inspect my re-readings, and for some reason I can't locate this issue within the php.ini file, but for some reason my PHP code doesn't require me to use the delimiter (the semi-colon) at the end of each of my statements. I want to expose all errors and notices (which lead me to set error_reporting to E_ALL & E_NOTICE) and I have display_errors set to on.

Is there a specific section of the php.ini file that allows users to not place semi-colons at the end of their statements?

For example if I put (without the semicolon)

echo 'some statement here'

The output would be

some statement here

The output should be something like:

Parse_error: syntax_error

That is telling me that I'm missing the semi-colon.

HELP MEEE!!!!!!!!!!!!!!!!!!


13.

None

Topic: Class Help

Posted: 01/23/09 11:58 AM

Forum: Programming

The solution:

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class StudentGrade
{
private:
	int idNum;
	string studentName;
	int testScore;
	int possiblePoints;
	char letterGrade;
public:
	StudentGrade(int,string,int,int = 100);
};

StudentGrade::StudentGrade(int num, string name, int score, int points)
{
	double total;
	idNum = num;
	studentName = name;
	testScore = score;

	if (points == 0)
		possiblePoints = 1;
	else
		possiblePoints = points;

	total = static_cast<double>(testScore) / static_cast<double>(possiblePoints) * 100;
}

int main()
{
	StudentGrade studentOne(1000,"Samuel",83,100);
}

14.

None

Topic: Class Help

Posted: 01/23/09 11:30 AM

Forum: Programming

I'm in the process of doing a C++ exam and there's something I'm having trouble with. I don't want someone to give me an answer to my homework assignment ... I just need help figuring something out. Why won't the division operator work within a constructor (all other arithmetic operators are working fine when tested)? The division operator is defaulting to "0" instead of giving me the expected double value that I need to determine other sequences of this project. Now, I know what I just wrote is kind of ambiguous ... however, I will give you this information:

My class variables are private ... do I need to make these variables protected? Or, does that have nothing to do with what I'm trying to accomplish?

An excerpt of the code:

#include "stdafx.h"
#include <iostream>
#include <string>

using namespace std;

class StudentGrade
{
private:
    int idNum;
    string studentName;
    int testScore;
    int possiblePoints;
    char letterGrade;
public:
    StudentGrade(int,string,int,int = 100);
};

StudentGrade::StudentGrade(int num, string name, int score, int points)
{
    double total;
    idNum = num;
    studentName = name;
    testScore = score;

    if (points == 0)
        possiblePoints = 1;
    else
        possiblePoints = points;

    total = testScore / possiblePoints;
    cout << total << endl;
}


int main()
{
    StudentGrade studentOne(1000,"Samuel *******",83);
}

15.

None

Topic: Notepad++

Posted: 09/25/08 04:07 PM

Forum: Programming

How do you get the function list to show all the functions that are created in your files?


16.

None

Topic: Simple C++ Calculator

Posted: 09/23/08 08:52 PM

Forum: Programming

At 9/23/08 02:44 PM, liaaaam wrote: Lol. You had the time to make a useless class (1+1 needs its own function?) but don't have time to do, what you describe as, "easy string manipulation". Hmm :P

I'll take the challenge. I'll code the stack, algorithm, and everything that deals with the challenge in a little while. I'll take the challenge a little farther than what it was originally posted ... I'll store the contents of the stack in an external file, read the contents from the file to populate the stack on the next running of the program ..... Users will have the option to erase all of the file and the contents of the stack and start fresh, or continue with the current estate of the stack and add more mathematical functions to the stack ....

FallingTears


17.

None

Topic: JavaScript Object Detection

Posted: 09/22/08 10:40 PM

Forum: Programming

Sorry for the third post, but I've got it. Thanks anyways


18.

None

Topic: JavaScript Object Detection

Posted: 09/22/08 09:50 PM

Forum: Programming

Sorry for the double post:

would this work?

	 function whatever(text, photo)
	 {
	 	if (document.getElementById(photo))
		{
			showIt(text);
			showIt(photo);
		}
		else
		{
			showIt(text);
		}
	 }

19.

None

Topic: JavaScript Object Detection

Posted: 09/22/08 09:42 PM

Forum: Programming

I have a bunch of picture files that are separated into either text images or photo images. Not all text images contains a photo image that goes with it. All photo images that goes with the text images has the same number as the text image, for example:

text1 & photo1
text2 & photo2

All text images and photo images are put within div elements ... the div id's contain either text1 or photo1 (etc for each text and photo pic file)

I have made a function that has the id passed to it for each text and photo file:

function whatever(text, photo) where text and photo are the id's of the divs containing each picture, respectively

How do I use object detection to see if the photo parameter has been used, or if it is empty?


20.

None

Topic: Random numbers visual basic 2008

Posted: 09/22/08 07:28 PM

Forum: Programming

Sorry for the double-post,

This does the same thing as my previous post:

        Randomize()
        Rnd()

        Dim randomNum As Integer
        randomNum = CInt(10 * Rnd() + 1)  ' Outputs a number between 1 and 10, including 1 & 10

        Me.xDisplayLabel.Text = CStr(randomNum)

Notice how much simpler my previous code is .... this is because Microsoft already defined the Random Number Generator in a classed called Random. They used some of the same type of math used in this post (see the code block above) to create the Random class.

Both way's aren't that random. Both are psuedo random numbers. To create a truly randomized number you have to create your own algorithm, which takes a lot of math.

Invoking a New Random starts the process. Then using the Random Class member "Next" instantiates the new random number.

FallingTears


21.

None

Topic: Random numbers visual basic 2008

Posted: 09/22/08 07:21 PM

Forum: Programming

It's simple to create a Random Number in VB.NET. There's this lovely Random Number psuedo class which outputs random numbers. After a while, the numbers begin repeating themselves in a certain pattern ... to create a true random number you'd have to come up with your own algorithm, but the basics of creating random numbers in VB.NET:

Smaller programs that use random numbers will follow this idea

        Dim Num As New Random
        Dim RandomNum As Integer

        RandomNum = Num.Next(minValue, maxValue)

minValue and maxValue are the minimum and maximum values, plus all the values inbetween, that you want to be assigned in the RandomNum when the number is generated.


22.

None

Topic: Simple C++ Calculator

Posted: 09/22/08 06:59 PM

Forum: Programming

Upgrade made for the file ... I'm disregarding the "stack" challenge, because I don't have the time to deal with it right now. People will come up with their own conclusions why I'm disregarding it ... it doesn't matter what you believe, because I don't have to answer to you anyway:

calc.h

// File name: calc.h
// Class name: Calculator
// Purpose: A definition of the calculator.
// By: FallingTears

class Calculator
{
	public:
		int Addition(int, int);
		int Subtraction(int, int);
		int Multiplication(int, int);
		int Division(int, int);
	private:
};

// implementation section

int Calculator::Addition(int num1, int num2)
{
	int answer = num1 + num2;
	return answer;
}

int Calculator::Subtraction(int num1, int num2)
{
	int answer;
	if (num1 >= num2)
	{
		answer = num1 - num2;
	}
	else if (num2 >= num1)
	{
		answer = num2 - num1;
	}

	return answer;
}

int Calculator::Multiplication(int num1, int num2)
{
	int answer = num1 * num2;
	return answer;
}

int Calculator::Division(int num1, int num2)
{
	int answer;
	
	if (num1 > num2)
	{
		answer = num1 / num2;
	}
	else
	{
		answer = num1 / num2;
	}

	return answer;
}

calculator.cpp

// File name: calculator.cpp
// Purpose:  Simple Integral Calculator for Elementary Students
// Created by: FallingTears

#include <iostream>
#include "calc.h"

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

//*****Function Prototypes*****

void miniMenu(int);
void menu();
void clearScreen();
void selection(int);
int endMenu();

int main()
{
	int option = 0;
	
	while (option >= 0)		// Causes the program to loop so that it can be used more than once
	{
		int choice			= 0;
		
		menu();
		cin >> choice;
		
		selection(choice);

		option = endMenu();
	}
	
	return 0;
}	// End of main function

//*****Function Definitions*****

void miniMenu(int num)
{
	int num1, num2, ans;
	Calculator calc;
	
	switch (num)
	{
		case 1:
			cout << "Simple Addition." << endl << endl;
			do	// Don't allow negative numbers to be entered
			{			
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 < 0 || num2 < 0);
			
			ans = calc.Addition(num1, num2);
			cout << ans;
			
			break;
		case 2:
			cout << "Simple Subtraction." << endl;
			cout << endl << "If the second number is greater than the first, then the second " << endl;
			cout << "number will be subtracted by the first." << endl << endl;
			
			do	// Don't allow negative numbers to be entered
			{	
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 < 0 || num2 < 0);

			ans = calc.Subtraction(num1, num2);
			cout << ans;

			break;
		case 3:
			cout << "Simple Multiplication." << endl << endl;
			
			do	// Don't allow negative numbers to be entered
			{			
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 < 0 || num2 < 0);

			ans = calc.Multiplication(num1,num2);
			cout << ans;

			break;
		case 4:
			cout << "Simple Division," << endl;
			cout << endl << "If the second number is greater than the first, then the second " << endl;
			cout << "number will be divided by the first." << endl << endl;
			
redo:		do	// Don't allow negative numbers to be entered
			{
					cout << "Enter the first number: ";
					cin >> num1;
					cout << "Enter the second number: ";
					cin >> num2;
			} while (num1 <= 0 || num2 <= 0 );	// Never allow divide-by-zero

			if (num1 > num2)
			{
				if (num1 % num2 != 0)	// prevent non-integer answers of division
				{
					goto redo;
				}
				else
				{				
					ans = calc.Division(num1, num2);
					cout << ans;
				}
				break;
			}
			else
			{
				if (num2 % num1 != 0)	// prevent non-integer answers of division
				{
					goto redo;
				}
				else
				{				
					ans = calc.Division(num1, num2);
					cout << ans;
				}
				break;
			}
	}
}	// End of miniMenu function

void menu()
{
		cout << "Simple C++ Calculator" << endl;
		cout << "Version: 1.50" << endl;
		cout << "Author: FallingTears" << endl << endl;
		cout << "Menu: " << endl;
		cout << "1. Addition " << endl;
		cout << "2. Subtraction " << endl;
		cout << "3. Multiplication " << endl;
		cout << "4. Division " << endl;
		cout << "Select an option from the menu above: (-1 to Exit) ";

}

void clearScreen()
{
	system("cls");
}	// end of clearScreen function

void selection(int num)
{
	 switch (num)
     {
		case 1:
			clearScreen();
			miniMenu(num);
			
			break;
		case 2:
			clearScreen();
			miniMenu(num);
			
			break;
		case 3:
			clearScreen();
			miniMenu(num);
			
			break;
		case 4:
			clearScreen();
			miniMenu(num);
						
			break;
     }
}	// End of selection function

int endMenu()
{
		int option = 0;

		cout << endl << endl;
		cout << "Do you want another calculation? (-1 To Exit, Any Positive Num to Continue) ";
		cin >> option;

		clearScreen();
		return option;
}	// End of endMenu function

I have done some research continue or break cannot be used in place of the goto command in C++. In fact, there is no replacement for the "goto" command, so I'm searching for another way to resolve this problem.


23.

None

Topic: Simple C++ Calculator

Posted: 09/19/08 03:24 PM

Forum: Programming

At 9/19/08 11:59 AM, RageOfOrder wrote:
At 9/19/08 09:49 AM, authorblues wrote:
At 9/18/08 10:21 PM, polym wrote: It pushes all operands onto the stack, then if it encounters an operator, it removes all elements from the stack and replaces it with the result.
Well, rather than having to do each operation individually he would be able to just input a string equation and let the program solve it.

I'm guessing that's a little above the OP's C++ knowledge though

It's not above my C++ knowledge ... string manipulation is my area of expertise. I know that Visual Basic isn't the same as C++, but I have written hundreds of Visual Basic programs manipulating strings ... and guess what, all string manipulation techniques used in VB is also implemented in C++. The program you described would have a very simple algorithm ... in fact, I have thought of three different algorithms that would work for this.

Tonight, when I get some free time ... I will use all three algorithms and post them here to show how simple C++ string manipulation can be.

Take a look at my C++ tutorial: Win Forms Made Easy, that should begin to show you the scope of my understanding of C++


24.

None

Topic: Simple C++ Calculator

Posted: 09/18/08 09:43 PM

Forum: Programming

I noticed a couple of more mistakes in my C++ source file, so I revamped the source file and here it is:

#include <iostream>

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

int main()
{
	int option = 0;
	
	while (option >= 0)		// Causes the program to loop so that it can be used more than once
	{
		int num1, num2		= 0;
		int ans				= 0;
	
		cout << "Simple C++ Calculator" << endl;
		cout << "Version: 0.83" << endl;
		cout << "Author: FallingTears" << endl << endl;
		cout << "Menu: " << endl;
		cout << "1. Addition " << endl;
		cout << "2. Subtraction " << endl;
		cout << "3. Multiplication " << endl;
		cout << "4. Division " << endl;
		cout << "Select an option from the menu above: (-1 to Exit) ";
		cin >> option;
	
		if (option == 1)
		{
			system("cls");
			cout << "Simple Addition." << endl << endl;
			
			do	// Don't allow negative numbers to be entered
			{			
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 <= 0 || num2 <= 0);
	
			ans = num1 + num2;
	
			cout << "Answer: " << ans;
		}
		
		if (option == 2)
		{
			system("cls");
			cout << "Simple Subtraction." << endl;
			cout << endl << "If the second number is greater than the first, then the second " << endl;
			cout << "number will be subtracted by the first." << endl << endl;
			
			do	// Don't allow negative numbers to be entered
			{	
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 <= 0 || num2 <= 0);
			
			if (num1 > num2)	// Never allow a negative answer
			{
				ans = num1 - num2;
			}
			else
			{
				ans = num2 - num1;
			}
	
			cout << "Answer: " << ans;
		}
		
		if (option == 3)
		{
			system("cls");
			cout << "Simple Multiplication." << endl << endl;
			
			do	// Don't allow negative numbers to be entered
			{			
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 <= 0 || num2 <= 0);
	
			ans = num1 * num2;
	
			cout << "Answer: " << ans;
		}
		
		if (option == 4)
		{
			system("cls");
			cout << "Simple Division," << endl;
			cout << endl << "If the second number is greater than the first, then the second " << endl;
			cout << "number will be divided by the first." << endl << endl;
			
redo:		do	// Don't allow negative numbers to be entered
			{
					cout << "Enter the first number: ";
					cin >> num1;
					cout << "Enter the second number: ";
					cin >> num2;
			} while (num1 < 0 || num2 < 0 );	// Never allow divide-by-zero, never allow remainders
			
			if (num1 > num2)	// Never allow fractional division, integers are being used.
			{
				if (num1 % num2 != 0)
				{
					num1 = 0;
					num2 = 0;
					goto redo;
				}
				else
				{
					ans = num1 / num2;
				}
			}
			else if (num2 > num1)
			{
				if (num2 % num1 != 0)
				{
					num1 = 0;
					num2 = 0;
					goto redo;
				}
				else
				{
					ans = num2 / num1;
				}
			}
						
			cout << "Answer: " << ans;
		}
		
		cout << endl << endl;
		cout << "Do you want another calculation? (-1 To Exit, Any Positive Num to Continue) ";
		cin >> option;
		system("cls");
	}
	
	return 0;
}	// End of main function

25.

None

Topic: Simple C++ Calculator

Posted: 09/18/08 09:35 PM

Forum: Programming

Sorry for the double post.

Well, I've corrected some things in the code (while the code works, I've made it a little better).

I've replaced all the single

cout << endl;

lines, and added this to the line before:

cout << "Stuff" << endl << endl;

So, it uses a few less lines than the previous edition.


26.

None

Topic: Simple C++ Calculator

Posted: 09/18/08 09:33 PM

Forum: Programming

The following code works excellently, but I'm using two goto commands. I've thought about using functions, or classes (to make an object oriented program). Maybe there's another way to do this besides using functions or classes, so here is my code:

#include <iostream>

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

int main()
{
	int option = 0;
	
	while (option >= 0)		// Causes the program to loop so that it can be used more than once
	{
		int num1, num2		= 0;
		int ans				= 0;
	
		cout << "Simple C++ Calculator" << endl;
		cout << "Version: 0.82" << endl;
		cout << "Author: FallingTears" << endl;
		cout << endl;
		cout << "Menu: " << endl;
		cout << "1. Addition " << endl;
		cout << "2. Subtraction " << endl;
		cout << "3. Multiplication " << endl;
		cout << "4. Division " << endl;
		cout << "Select an option from the menu above: (-1 to Exit) ";
		cin >> option;
	
		if (option == 1)
		{
			system("cls");
			cout << "Simple Addition." << endl;
			cout << endl;
			
			do	// Don't allow negative numbers to be entered
			{			
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 <= 0 || num2 <= 0);
	
			ans = num1 + num2;
	
			cout << "Answer: " << ans;
		}
		
		if (option == 2)
		{
			system("cls");
			cout << "Simple Subtraction." << endl;
			cout << endl << "If the second number is greater than the first, then the second " << endl;
			cout << "number will be divided by the first." << endl << endl;
			
			do	// Don't allow negative numbers to be entered
			{	
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 <= 0 || num2 <= 0);
			
			if (num1 > num2)	// Never allow a negative answer
			{
				ans = num1 - num2;
			}
			else
			{
				ans = num2 - num1;
			}
	
			cout << "Answer: " << ans;
		}
		
		if (option == 3)
		{
			system("cls");
			cout << "Simple Multiplication." << endl;
			cout << endl;
			
			do	// Don't allow negative numbers to be entered
			{			
				cout << "Enter the first number: ";
				cin >> num1;
				cout << "Enter the second number: ";
				cin >> num2;
			} while (num1 <= 0 || num2 <= 0);
	
			ans = num1 * num2;
	
			cout << "Answer: " << ans;
		}
		
		if (option == 4)
		{
			system("cls");
			cout << "Simple Division," << endl;
			cout << endl << "If the second number is greater than the first, then the second " << endl;
			cout << "number will be divided by the first." << endl << endl;
			
redo:		do	// Don't allow negative numbers to be entered
			{
					cout << "Enter the first number: ";
					cin >> num1;
					cout << "Enter the second number: ";
					cin >> num2;
			} while (num1 < 0 || num2 < 0 );	// Never allow divide-by-zero, never allow remainders
			
			if (num1 > num2)	// Never allow fractional division, integers are being used.
			{
				if (num1 % num2 != 0)
				{
					num1 = 0;
					num2 = 0;
					goto redo;
				}
				else
				{
					ans = num1 / num2;
				}
			}
			else if (num2 > num1)
			{
				if (num2 % num1 != 0)
				{
					num1 = 0;
					num2 = 0;
					goto redo;
				}
				else
				{
					ans = num2 / num1;
				}
			}
						
			cout << "Answer: " << ans;
		}
		
		cout << endl << endl;
		cout << "Do you want another calculation? (-1 To Exit, Any Positive Num to Continue) ";
		cin >> option;
		system("cls");
	}
	
	return 0;
}	// End of main function

27.

None

Topic: Notepad2, Notepad++, Or Pspad

Posted: 09/18/08 08:55 PM

Forum: Programming

Awesome,

I have a new code editor!


28.

None

Topic: PHP question

Posted: 09/18/08 08:31 PM

Forum: Programming

At 9/18/08 08:26 PM, SilvaWolf wrote: Yeah the second one should work, I was just looking for a more effecient way because i thought there was one.
Break; will stop execution of the while loop, but if you use break it would stop at 2 then end the script. Oh and please excuse my syntax in my first post, i used this example instead of posting the large amounts of code in my project

Break would stop after the first increment, since I used the if ($i != 3) .... instead of using the break command within that if code block, just use it for whatever condition you want to use it for ... once that condition has been met.


29.

None

Topic: PHP question

Posted: 09/18/08 08:22 PM

Forum: Programming

Your code:

$i=0;
while($i<=10)
   {
        $i++;
        if($i==3)
           {
                 // CODE HERE
           };                                                               // Mistake on this line, the ";" is not needed after an ending curly brace
   echo "The number is " . $i . "<br />";         // Prints all numbers including 3
 }

Each number will be displayed in this while loop. You misunderstand the code, to keep three from being displayed you would have to change your code to this:

$i=0;
while($i<=10)
   {
        $i++;                   // $i is incremented here
        if($i == 3)
           {
                 // CODE HERE
           }
        if($1 != 3)
        {
                  echo "The number is " . $i . "<br />";          // Prints all the numbers, except 3
        }
 }

You expert code geniuses can correct me if you want, but I believe to exit a while loop before certain conditions are met you need to use the break command, like so:

$i=0;
while($i<=10)
   {
        $i++;                   // $i is incremented here
        if($i == 3)
           {
                 // CODE HERE
                 break (label/function?);             // break from the while loop and go to a certain label or function?
           }
        if($1 != 3)
        {
                  echo "The number is " . $i . "<br />";          // Prints all the numbers, except 3
                  break (label/function?);            // break from the while loop and go to a certain label or function?
        }
 }

30.

None

Topic: Notepad2, Notepad++, Or Pspad

Posted: 09/18/08 08:07 PM

Forum: Programming

I've been evaluating, for my own personal reasons, notepad2, PSPad, and notepad++. I'm wondering, which version do you guys prefer? Personally, I prefer notepad++ and PSPad, because they provide tabs to allow multiple files to be edited/changed. Between notepad++ and PSPad, I prefer notepad++, because I've discovered a glitch with PSPad. Sometimes, PSPad doesn't allow itself to be minimized or allow a person to switch between it and other programs that are running (example: IE or Firefox). Because of that glitch, I've decided to ditch PSPad.

I like the syntax highlighting of notepad2 over the syntax highlighting of notepad++. I find it much easier to edit files, because of the darker, bolder colors of notepad2. What do you guys think of the syntax highlighting of notepad2?

Can I edit the syntax highlighting of notepad++... if I can, I know that notepad++ will replace notepad2.

My ratings (5 star rating system, where 1 star is worse and 5 stars is best):

notepad2 - ****
notepad++ - ****
pspad - ***


All times are Eastern Standard Time (GMT -5) | Current Time: 05:39 AM

<< < > >>

Viewing 1-30 of 252 matches. 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9