Potion Decant Calculator

Discussion in 'Programming General' started by T7 Press 7T, May 29, 2012.

Potion Decant Calculator
  1. Unread #1 - May 29, 2012 at 6:36 PM
  2. T7 Press 7T
    Joined:
    Jun 14, 2007
    Posts:
    384
    Referrals:
    0
    Sythe Gold:
    0

    T7 Press 7T Forum Addict

    Potion Decant Calculator

    For whatever reason this morning I felt the need to use a potion decant calculator and couldn't find one so I made one. At the time I didn't know the formula:
    Code:
    potionAmount * .75 = fullPotions;
    so I just made my own way to do it.

    This one counts the empty and other filled vial types.

    Screen:
    [​IMG]
    Scan:
    http://virusscan.jotti.org/en/scanresult/7334330a375375e356e24cde56933a2a79ac00ab
    File:
    http://www.sendspace.com/file/fzohe4

    Code:
    #include <iostream>
    
    using namespace std;
    
    int main() {
    
    	int potAmount;
    	int counter = 0;
    	int pot4 = 0, pot3, pot2 = 0, pot1 = 0, pot0 = 0, currPot = 3;
    
    	cout << "Please enter the total potion amount: ";
    	cin >> potAmount;
    	pot3 = potAmount;
    
    	for ( int loop = 0; loop < potAmount; loop++ ) {
    		switch (currPot) {
    		case 3:
    			currPot--;
    			pot4++;
    			pot3--;
    			pot2++;
    			break;
    		case 2:
    			currPot--;
    			pot4++;
    			pot2--;
    			pot1++;
    			break;
    		case 1:
    			currPot--;
    			pot4++;
    			pot1--;
    			break;
    		case 0:
    			currPot = 3;
    			pot0++;
    			break;
    		}
    	}
    
    	cout << "You have " << pot4 << " 4 dose potions." << endl;
    	cout << "You have " << pot2 << " 2 dose potions." << endl;
    	cout << "You have " << pot1 << " 1 dose potions." << endl;
    	cout << "You have " << pot0 << " empty vials" << endl;
    
    	system("pause");
    	return 0;
    }
    
    I'm fully aware "system("pause");" is pretty lame, but Visual Studio isn't letting me pause any other way; even with simple "cin.get()".
     
  3. Unread #2 - Sep 7, 2012 at 2:28 PM
  4. Fox.
    Joined:
    Aug 31, 2011
    Posts:
    520
    Referrals:
    0
    Sythe Gold:
    131
    Discord Unique ID:
    230355826332794881
    Discord Username:
    Xyz#9568

    Fox. Forum Addict
    $5 USD Donor New

    Potion Decant Calculator

    Try flushing the cin buffer at the end.

    Code:
    cin.ignore(std::numeric_limits<std::streamsize>::max());
    cin.get();
    return 0;
     
  5. Unread #3 - Oct 4, 2012 at 5:25 PM
  6. Blupig
    Joined:
    Nov 23, 2006
    Posts:
    7,145
    Referrals:
    16
    Sythe Gold:
    1,609
    Discord Unique ID:
    178533992981594112
    Valentine's Singing Competition Winner Member of the Month Winner MushyMuncher Gohan has AIDS Extreme Homosex World War 3 I'm LAAAAAAAME
    Off Topic Participant

    Blupig BEEF TOILET
    $5 USD Donor

    Potion Decant Calculator

    +1 on using iostream, it's so painful when I see people using c functions like printf in C++
     
< IT Questions | Simplicity >

Users viewing this thread
1 guest


 
 
Adblock breaks this site