Results 1 to 2 of 2
  1. #1
    Cerberus
    Join Date
    Oct 2008
    Posts
    436
    BG Level
    4

    c++ convert functiont to class

    I need to convert this:

    Code:
    #include <iostream>
    
    using namespace std;
    
    
    //Displays current balance
    void menu1(float balance){
        cout << "Your current balance is: "<<balance<<endl;
        system ("PAUSE");
    }
    //deposit
    void menu2(float balance){
    	float numb = 0;
    	cout << "How much would you like to deposit today: ";
    	cin >> numb;
    	float dtotal = balance + numb;
    	cout << "you current balance is: "<<dtotal<<endl;	
        system ("PAUSE");
    }
    //withdraw
    void menu3(float balance){
    	float withdraw = 0;
    	cout << "How much would you like to withdraw today: ";
    	cin >> withdraw;
    	float wtotal = balance - withdraw;
    	cout << "you current balance is: "<<wtotal<<endl;	
        system ("PAUSE");
    }
    
    void main() {
        int menu;
        int triger = 0;
    	int balance = 2000;
    			
     	while(triger==0){
    		cout << "1. Get a balance inquiry." << endl;
            cout << "2. Make a deposit." << endl;
    		cout << "3. Make a withdrawal." << endl;	
    		cout << "4. Exit." << endl;
    		cout << "what would you like to do?:";
    		cin >> menu;
            switch (menu){
                case 1:
    				//Current balance
                    menu1(balance);
    				break;
                case 2://does the deposit
    				menu2(balance);
    				break;
                case 3://does the withdrawal
    				menu3(balance);
    				break;
                default:// exit out the loop
    				cout << "Thank you, have a nice day" << endl;
                    system ("PAUSE");
    				triger=1;
            }
            system ("cls");
        }
    }

    Into a class style. What is the easiest way?

  2. #2
    Banned.

    Join Date
    Oct 2006
    Posts
    10,115
    BG Level
    9

    use your previous program

Similar Threads

  1. Replies: 6
    Last Post: 2018-05-15, 22:02
  2. Program to convert music files
    By Oxyminus in forum Tech
    Replies: 1
    Last Post: 2008-12-02, 00:53
  3. Converting .cue/.bin to .mp4
    By Gafgarionn in forum Tech
    Replies: 3
    Last Post: 2008-11-13, 11:45
  4. Convert .doc to .pdf ?
    By Katalya in forum Tech
    Replies: 5
    Last Post: 2008-01-10, 23:12
  5. Converting video files to .WMV for the 360
    By Lockecole in forum Tech
    Replies: 6
    Last Post: 2007-10-12, 17:46