Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › How do I give my C++ program a GUI / Turn it into a .exe?
New Posts  All Forums:Forum Nav:

How do I give my C++ program a GUI / Turn it into a .exe?

post #1 of 9
Thread Starter 
I'm taking this computer science class and I'm learning how to program in C++. This week we are supposed to make any program we want. I was bored on Friday night so I wrote up a quick program for my friends and I to help us compare the value of different alcoholic beverages. It basically calculates how much you are paying for an ounce of pure alcohol, and how many ounces of pure alcohol are present (BTW, somebody want to double check the math for me?). It also converts milliliters to ounces, and allows you to calculate for a whole case of beer by only using the volume of one can of beer multiplied by the number of cans in a case.

Anyway, I want to know how to create an executable application so I can put it on my friends' computers. I also want to create a graphical user interface, seeing as they aren't computer savvy enough to operate anything command line-like in nature. Any tips?

Bonus points: I want to create a database so we can call up previously entered data, how would I go about doing this? My teacher hasn't covered this but I want to do it.

I downloaded Visual Basic 2008 and C++ editions, but I'm not sure where to input the code.

Code:
// Calculates cost of one ounce of pure alcohol

#include <iostream>
using namespace std;

int main()
{

        float proof, volume, beerc, beerv, price, worth, content, ml;
        char beeryn;    // beer yes or no
        char help;      // need help converting yes or no



        cout << "n" << endl;
        cout << "***********************************************************" << endl;
        cout << "* This program calculates how much you are paying for an  *" << endl;
        cout << "* ounce of pure alcohol when you buy booze. This can be   *" << endl;
        cout << "* used as an effective way of comparing the value of one  *" << endl;
        cout << "* spirit versus another.                                  *" << endl;
        cout << "***********************************************************" << endl;
        cout << "                   *     Created by    *" << endl;
        cout << "                   *  Samuel J. Cashen *" << endl;
        cout << "                   *********************" << endl;                    
        cout << "n";
        cout << "First, do you need help converting from milliliters to ounces?";
        cout << " (Y or N): ";
        cin >> help;

        if ((help == 'Y') || (help == 'y'))
        {
        cout << "How many milliliters is it? ";
        cin >> ml;
        volume = ml * 0.0338140226;
        cout << ml << " milliliters is equal to " << volume << " ounces" << endl;
        }

        cout << "Is this beer? (Y or N) ";
        cin >> beeryn;

        if ((beeryn == 'Y') || (beeryn == 'y'))
        {
        cout << "Enter number of beers in case: ";
        cin >> beerc;
        cout << "Enter volume of one can of beer in ounces: ";
        cin >> beerv;
        volume = beerv * beerc;
        }

        if (((beeryn == 'N') || (beeryn == 'n')) && ((help == 'N') || (help == 'n')))
        {
        cout << "Enter the volume in ounces: ";
        cin >> volume;
        }

        cout << "Enter the proof: ";
        cin >> proof;

        cout << "Enter the price: $";
        cin >> price;

        content = (volume)  * ( proof / 200 );

        worth = (price) / (content);

        cout << "There are " << content << " ounces of pure alcohol" << endl;
        cout << " which you are paying for at a rate of $" << worth << endl;
        cout << " per ounce of pure alcohol." << endl;

        return 0;
}

**Also:
Any suggestions to the code would be phenomenal. I considered dividing it into functions, but I'm a little weak in that area since we haven't covered them too much. Besides, it's a really short program, functions would just make it longer. Any ideas?
post #2 of 9
The C++ WinAPI for GUI in windows is pretty complicated. By the sound of it, your skill isn't developed enough and I would just try and learn the basics like functions and console commands if I was you. Console should be plenty for the type of program you are making.
post #3 of 9
you could always recode it in java and use netbeans to make a GUI automatically for you . But yeah, if you don't know how to code a GUI, it's a lot of work in C++, especially for a program like that.
post #4 of 9
Yeah, I took a look at what it takes just to call up a window. It scared me.
Cataclysm
(20 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 GA-EP45-UD3P Rev. 1.0 Sapphire 4850 4x 2GB DDR2-1066 
Hard DriveHard DriveOptical DriveCooling
WD1600AAJS Random IDE Sony DVD Burner Tuniq Tower 120 
CoolingCoolingCoolingOS
6x 120mm Scythe SY1225SL12SH Fans Thermalright T-RAD2 2x 92mm Scythe DFS922512M-PWM Fans Windows 7 Ultimate x64 SP1 
MonitorMonitorKeyboardPower
Acer 19" @ 1400x900 Sceptre 19" @ 1280x1024 Cherry G81-7000LPAUS-2 (MY Switches) Corsair 650TX 
CaseMouseMouse PadAudio
Antec 900 Razer Diamondback 3G A black one with a cat in a hammock Asus Xonar D1 
  hide details  
Reply
Cataclysm
(20 items)
 
  
CPUMotherboardGraphicsRAM
Q6600 G0 GA-EP45-UD3P Rev. 1.0 Sapphire 4850 4x 2GB DDR2-1066 
Hard DriveHard DriveOptical DriveCooling
WD1600AAJS Random IDE Sony DVD Burner Tuniq Tower 120 
CoolingCoolingCoolingOS
6x 120mm Scythe SY1225SL12SH Fans Thermalright T-RAD2 2x 92mm Scythe DFS922512M-PWM Fans Windows 7 Ultimate x64 SP1 
MonitorMonitorKeyboardPower
Acer 19" @ 1400x900 Sceptre 19" @ 1280x1024 Cherry G81-7000LPAUS-2 (MY Switches) Corsair 650TX 
CaseMouseMouse PadAudio
Antec 900 Razer Diamondback 3G A black one with a cat in a hammock Asus Xonar D1 
  hide details  
Reply
post #5 of 9
i know c++ is more efficient than java, but man do i hate coding in it. what i can code in 15 minutes in java takes me a couple hours in c++, i just hate all the pointer business...get that junk outta here.
post #6 of 9
Haha, the premise of this program is hilarious. Calculating which beer gives you the most alcohol for the money.. Brilliant!

This would do well on cell phones.
HP Pavilion dm1z
(13 items)
 
  
CPUGraphicsRAMHard Drive
Fusion E-350 Radeon HD 6310M 8GB Corsair DDR3 Western Digital Scorpio Black 750GB 
OSMonitor
Windows 7 Home Premium 11.6" 
  hide details  
Reply
HP Pavilion dm1z
(13 items)
 
  
CPUGraphicsRAMHard Drive
Fusion E-350 Radeon HD 6310M 8GB Corsair DDR3 Western Digital Scorpio Black 750GB 
OSMonitor
Windows 7 Home Premium 11.6" 
  hide details  
Reply
post #7 of 9
C# is actually pretty nifty. Visually create GUI with Visual Studio. Its sorta like a mix of C++ and Java.
post #8 of 9
Look in your documents, open the Visual Studio folder then the projects folder then the bin folder.
Lee XT
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Vertex 4 256GB 
CoolingOSMonitorKeyboard
Corsair H80 Windows 8.1 Pro MCE Dell P2414H WHXV7  Microsoft Generic 
PowerCaseMouseMouse Pad
Ultra 600W Limited Edition NZXT Black Steel Razer Deathadder Razer Goliath 
Audio
Realtek HD Audio 
  hide details  
Reply
Lee XT
(17 items)
 
  
CPUMotherboardGraphicsRAM
AMD FX-6300 Asus M5A97 SAPPHIRE Radeon HD 7850 AMD 4GB DDR3 1333MHZ 
RAMRAMRAMHard Drive
AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ AMD 4GB DDR3 1333MHZ OCZ Vertex 4 256GB 
CoolingOSMonitorKeyboard
Corsair H80 Windows 8.1 Pro MCE Dell P2414H WHXV7  Microsoft Generic 
PowerCaseMouseMouse Pad
Ultra 600W Limited Edition NZXT Black Steel Razer Deathadder Razer Goliath 
Audio
Realtek HD Audio 
  hide details  
Reply
post #9 of 9
Thread Starter 
Quote:
Originally Posted by korosu View Post
Haha, the premise of this program is hilarious. Calculating which beer gives you the most alcohol for the money.. Brilliant!

This would do well on cell phones.
That's exactly what I was going to do with it next! If I can figure out how to do that I'll post it. I'll probably try to program it for my Sony Ericcson w810i.


Thanks for the info guys. Yeah, sounds like I need to wait a while to attempt a GUI with C++. I'll keep messing with Visual Basic in my free time. I'll post it if I can get it done

+rep to those with good advice. Thanks fellas.
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › How do I give my C++ program a GUI / Turn it into a .exe?