[ create a new paste ] login | about

Link: http://codepad.org/wQGJ6dV4    [ raw code | output | fork ]

C++, pasted on Oct 26:
#include <iostream>
#include <string>
#include <iomanip>


using namespace std;

class drinkClass
{
    public:
        string name[5];
        double cost[5];
        int num[5];
    
        void dispList() {
            cout << "Drink Name             Cost            Number in Machine" << endl;
            for (int c = 0; c < 5; c++) {
                cout << c+1 << left << setw(10) << name[c] << "        ";
                cout << setw(10) << cost[c] << "        ";
                cout << setw(10) << num[c] << endl;
            }
        }
    
        int pickDrink() {
            return 0;
        }
        
        double insertMoney() {
            return 0;
        }
        
        double calcChange() {
            return 0;
        }
        
        double setCurrency(double x) {
            double y = x * .0001;
         /*   cout << fixed;
            cout << setprecision(2);*/
            return y;
        }
        
        void quit() {
            
        }
        
    private:
        
};

void test()
{
    
}

int main()
{
    drinkClass drink;
    
    string list[5] = 
    {"Cola", "Root Beer", "Lemon-Lime", "Grape Soda", "Cream Soda"};
            
    //names and number
    for (int c = 0; c < 5; c++) {
        drink.name[c] = list[c];
        drink.num[c] = 20;
    }
    
    //cost
    for (int c = 0; c < 5; c++) {
        drink.cost[c] = 7500;
        while (c > 1 && c < 4) {
            c++;
            drink.cost[c] = 8000;
        }
        
    }
    
    drink.dispList();
    
    cin.ignore();
    return 0;
}


Output:
1
2
3
4
5
6
Drink Name             Cost            Number in Machine
1Cola              7500              20        
2Root Beer         7500              20        
3Lemon-Lime        7500              20        
4Grape Soda        8000              20        
5Cream Soda        8000              20        


Create a new paste based on this one


Comments: