JackOfAllTrades's Profile User Rating: ****-

Reputation: 6135 Overlord
Group:
Moderators
Active Posts:
25,681 (10.93 per day)
Joined:
23-August 08
Profile Views:
213,366
Last Active:
User is offline Private
Currently:
Offline

Previous Fields

Country:
US
OS Preference:
Who Cares
Favorite Browser:
FireFox
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Mazda
Dream Kudos:
200
Expert In:
not much at all

Latest Visitors

Icon   JackOfAllTrades is missing compiled languages...

Posts I've Made

  1. In Topic: Compiler Error (... does not have class type)

    Posted 28 Jan 2015

    Don't know Qt, but looking at this, text is a function call, so that line should probably be

    return var=edit->text().toDouble();
    
  2. In Topic: Program loops back around after first menu

    Posted 27 Jan 2015

    Your indentation is screwed up, and it's screwing you up.

    Here's your file properly indented. Can you spot the problem?

    #include<iostream>
    #include<iomanip>
    #include<istream>
    #include<ostream>
    #include<string>
    using namespace std;
    
    
    struct Machine
    {
    	string soda;
    	double price;
    	int amt;
    };
    
    
    int main()
    {
    	const int index = 5;
    	int	drinkChoice;
    	int drinkSelection;
    	double userChoice,
    		   money = 0,
    		   change = 0,
    		   totalMoney = 0;
    
    	Machine sodaPop[index];
    			sodaPop[0].soda = "Cola";
    			sodaPop[1].soda = "Root Beer";
    			sodaPop[2].soda = "Lemon-Lime";
    			sodaPop[3].soda = "Grape Soda";
    			sodaPop[4].soda = "Cream Soda";
    	
    			sodaPop[0].price = 0.75;
    			sodaPop[1].price = 0.75;
    			sodaPop[2].price = 0.75;
    			sodaPop[3].price = 0.80;
    			sodaPop[4].price = 0.80;
    
    			sodaPop[0].amt = 20;
    			sodaPop[1].amt = 20;
    			sodaPop[2].amt = 20;
    			sodaPop[3].amt = 20;
    			sodaPop[4].amt = 20;
    
    	while (index == 5)
    	{
    		userChoice = 0;
    		
    		cout << "Enter (1) to order a drink.\n"  << "Enter (2) to check the inventory.\n" << "Enter (0) exit.\n" 
    			<< "Make a choice: ";
    		cin >>  userChoice;
    			
    		if (userChoice == 1)
    		{
    			cout << "\nAvailable drinks:" 
    				<< "\nEnter (1) for " << sodaPop[0].soda << " ---> $" << setprecision(2) << fixed << sodaPop[0].price 
    				<< "\nEnter (2) for " << sodaPop[1].soda << " ---> $" << setprecision(2) << fixed << sodaPop[1].price
    				<< "\nEnter (3) for " << sodaPop[2].soda << " ---> $" << setprecision(2) << fixed << sodaPop[2].price
    				<< "\nEnter (4) for " << sodaPop[3].soda << " ---> $" << setprecision(2) << fixed << sodaPop[3].price 
    				<< "\nEnter (5) for " << sodaPop[4].soda << " ---> $" << setprecision(2) << fixed << sodaPop[4].price << endl;
    
    			cout << "Make a choice: ";
    			cin >> drinkChoice;
    					
    			drinkSelection = drinkChoice - 1;
    
    			if (drinkSelection >=  0 && drinkSelection <= 4)
    			{
    				if (sodaPop[drinkSelection].amt > 0)
    				{
    					cout << "Please insert money ($1.00 or less): $";
    					cin >> money;
    				
    					if (money >= sodaPop[drinkSelection].price && money <= 1)	
    					{
    						change = money - sodaPop[drinkSelection].price;
    						sodaPop[drinkSelection].amt = sodaPop[drinkSelection].amt - 1;
    						totalMoney = sodaPop[drinkSelection].price + totalMoney;
    
    						cout << "\n" << sodaPop[drinkSelection].soda << " is dispensing.\n" 
    							<< "Your change is $" << setprecision(2) << fixed << change << "\n "<< endl;
    					}
    					else
    					{
    						cout << "\nThat is not a valid amount. Try again...\n" << endl;
    					} 
    				}
    				else if (sodaPop[drinkSelection].amt <= 0)
    				{
    					cout << sodaPop[drinkSelection].soda << " is sold out.\n" << endl;
    				}
    			}
    			else if (userChoice == 2)
    			{
    				cout << "\nInventory:\n" 
    					<< sodaPop[0].soda << " ---> " << sodaPop[0].amt << "\n"
    					<< sodaPop[1].soda << " ---> " << sodaPop[1].amt << "\n"
    					<< sodaPop[2].soda << " ---> " << sodaPop[2].amt << "\n"
    					<< sodaPop[3].soda << " ---> " << sodaPop[3].amt << "\n"
    					<< sodaPop[4].soda << " ---> " << sodaPop[4].amt << "\n" << endl;
    			}
    			else if (userChoice == 0)
    			{
    				cout << "\nThe amount of money the machine made is: $" << setprecision(2) << fixed << totalMoney 
    					<< "\n" << "\nThe vending machine is now closed.\n" << endl;
    
    				system("PAUSE");
    
    				exit(0);
    			}
    			else
    			{
    				cout << "\nThat is not a valid choice. Please try again...\n" << endl;
    			}
    		}
    
    	}
    	
    	return 0;
    }
    
    
    
  3. In Topic: Push linked list pointer problem

    Posted 27 Jan 2015

    Because you're changing the value of head in the function, you must pass that by pointer.

    void add_beg(struct node **head, int val);
    ...
    add_beg(&root, val); /* pass the address of the root ptr */
    ...
    void add_beg(struct node **head, int val)
    {
        struct node * newNode = malloc(sizeof(struct node));
    
        newNode->val = val;
        newNode->next = *head; /* set to the address contained in head */
        *head = newNode; /* set the address of the head to the new node */
    }
    
  4. In Topic: Networking

    Posted 27 Jan 2015

    http://beej.us/guide/bgnet/
  5. In Topic: php or wordpress

    Posted 24 Jan 2015

    Wordpress is the most widely-used PHP-based content management system (CMS), so if you're using Wordpress, you are using PHP. Unless you are a PHP expert, using the current version of Wordpress -- and keeping up with updates -- is going to be more far more secure than anything you can come up with.

My Information

Member Title:
Saucy!
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Location:
United States of Insanity
Interests:
Music, Sports, Games. The usual stuff.
Programming Languages:
C, C++, C#, PHP, Python, JavaScript, SQL, VB6, XML

Contact Information

E-mail:
Private
Website URL:
Website URL  http://