Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming

Reply
 
LinkBack Thread Tools
Old 02-26-08   #1 (permalink)
First Time Build
 
intel nvidia

Join Date: May 2007
Location: Ak
Posts: 53

Rep: 1 Ecko Unknown
Unique Rep: 1
Trader Rating: 0
Default How do I give my C++ program a GUI / Turn it into a .exe?

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?
__________________
System: Titan
CPU
C2D E6600
Motherboard
ASUS P5N32E-SLI
Memory
4x1GB DDR2 800 G.Skill HZ
Graphics Card
EVGA 8800 GTS 640MB
Hard Drive
2xSeagate Barracuda 7200.10
Sound Card
Creative Sound Blaster X-Fi XtremeGamer 7.1
Power Supply
Corsair 620HX
Case
Something cheap
CPU cooling
Tuniq Tower 120
OS
XP
Monitor
Samsung 226BW 22" LCD Monitor

Last edited by Ecko : 02-26-08 at 08:55 PM.
Ecko is offline   Reply With Quote
Old 02-26-08   #2 (permalink)
Intel Overclocker
 
dante020's Avatar
 
intel nvidia

Join Date: Sep 2007
Location: Novi, MI
Posts: 198

Rep: 34 dante020 is acknowledged by some
Unique Rep: 23
Folding Team Rank: 107
Trader Rating: 4
Default

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.
__________________
System: The System
CPU
Q6600 @ 3.2Ghz - 356FSB
Motherboard
Asus P5Q Pro
Memory
OCZ Platinum Rev. 2 4x1GB
Graphics Card
EVGA 8800GT 512MB
Hard Drive
WD Raptor 150GB x 2
Sound Card
Creative X-Fi XtremeGamer
Power Supply
Corsair CMPSU-620HX 620W
Case
Antec P180B
CPU cooling
Scythe Ninja SCNJ-1000
OS
Windows Vista Ultimate x64
Monitor
Samsung 226BW 22" LCD
dante020 is offline I fold for Overclock.net   Reply With Quote
Old 02-26-08   #3 (permalink)
Programmer
 
BiG O's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: University of Virginia
Posts: 2,053

Rep: 231 BiG O is acknowledged by manyBiG O is acknowledged by manyBiG O is acknowledged by many
Unique Rep: 178
Trader Rating: 2
Default

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.

System: My System
CPU
Q6700
Motherboard
Blood Iron
Memory
8GB Crucial Ballistix DDR2-800 (4x2GB)
Graphics Card
BFG 8800GTS 512MB g92
Hard Drive
2X 500GB Seagate Barracuda 7,200 RPM SATA RAID 0
Sound Card
Razer Barracuda AC-1 7.1Gaming Soundcard
Power Supply
ABS 700W Modular
Case
Antec 900
CPU cooling
Tuniq Tower 120
GPU cooling
Stock
OS
Vista Ultimate x64 SP1, Xubuntu 8.10
Monitor
Hanns-G 28" & Dell Ultrasharp 19" widescreen
BiG O is offline   Reply With Quote
Old 02-26-08   #4 (permalink)
Windows Wrangler
 
mrtn400's Avatar
 
intel ati

Join Date: Aug 2007
Location: Carmichael, CA
Posts: 3,073
Blog Entries: 2

Rep: 203 mrtn400 is acknowledged by manymrtn400 is acknowledged by manymrtn400 is acknowledged by many
Unique Rep: 173
Hardware Reviews: 1
Trader Rating: 0
Default

Yeah, I took a look at what it takes just to call up a window. It scared me.
__________________
Je parle un peu le français, mais je préfère parler l'anglais. Parlez-vous le français aussi?

For you English speakers:

">" - greater than; "<" - less than
"there" - Hey, look over there.
"their" - I love their Mustang.
"they're" - They're so lucky!

System: Cataclysm (Main Rig)
CPU
Q6600 G0 1.325v @ 3296Mhz (412x8) 1.41v
Motherboard
Abit IP35 Pro
Memory
4x 1GB Patriot DDR2-800 @ 812Mhz 4-4-4-12 2.15v
Graphics Card
Sapphire 4850 @ 725Mhz/1050Mhz w/ Catalyst 8.7
Hard Drive
2x WD1600AAJS RAID0
Sound Card
Onboard 7.1
Power Supply
Antec True Power Trio 650w
Case
Antec 900
CPU cooling
Tuniq Tower 120 w/ Scythe SY1225SL12SH 120mm
GPU cooling
Thermalright T-RAD² w/ 2x Scythe DFS922512M-PWM
OS
Windows Vista Ultimate x64 SP1
Monitor
1x Acer 19" @ 1400x900, 1x Sceptre 19" @ 1280x1024
mrtn400 is offline mrtn400's Gallery   Reply With Quote
Old 02-26-08   #5 (permalink)
Programmer
 
BiG O's Avatar
 
intel nvidia

Join Date: Jul 2007
Location: University of Virginia
Posts: 2,053

Rep: 231 BiG O is acknowledged by manyBiG O is acknowledged by manyBiG O is acknowledged by many
Unique Rep: 178
Trader Rating: 2
Default

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.

System: My System
CPU
Q6700
Motherboard
Blood Iron
Memory
8GB Crucial Ballistix DDR2-800 (4x2GB)
Graphics Card
BFG 8800GTS 512MB g92
Hard Drive
2X 500GB Seagate Barracuda 7,200 RPM SATA RAID 0
Sound Card
Razer Barracuda AC-1 7.1Gaming Soundcard
Power Supply
ABS 700W Modular
Case
Antec 900
CPU cooling
Tuniq Tower 120
GPU cooling
Stock
OS
Vista Ultimate x64 SP1, Xubuntu 8.10
Monitor
Hanns-G 28" & Dell Ultrasharp 19" widescreen
BiG O is offline   Reply With Quote
Old 02-26-08   #6 (permalink)
The 100 Mega Shock!
 
korosu's Avatar
 
intel nvidia

Join Date: Jan 2007
Location: COB Speicher, Iraq
Posts: 4,145

Rep: 267 korosu is a proven memberkorosu is a proven memberkorosu is a proven member
Unique Rep: 215
Folding Team Rank: 472
Trader Rating: 10
Default

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.
__________________
CPU-Z Validation GPU-Z Validation 3DMark06
PlayStation Network, Steam: jwhited

System: HP Pavilion dv5t
CPU
Core 2 Duo P8600
Motherboard
Intel "Cantiga" PM45/ICH9M
Memory
4GB G.Skill DDR2 800
Graphics Card
GeForce 9600M GT 512MB
Hard Drive
Western Digital Scorpio Black 320GB
Power Supply
6 Cell Battery
Case
Pavilion dv5 Chassis
OS
Windows Vista Home Premium x64 SP1
Monitor
HP 15.4" BrightView Infinity WSXGA+
korosu is offline I fold for Overclock.net Overclocked Account korosu's Gallery   Reply With Quote
Old 02-26-08   #7 (permalink)
Intel Overclocker
 
dante020's Avatar
 
intel nvidia

Join Date: Sep 2007
Location: Novi, MI
Posts: 198

Rep: 34 dante020 is acknowledged by some
Unique Rep: 23
Folding Team Rank: 107
Trader Rating: 4
Default

C# is actually pretty nifty. Visually create GUI with Visual Studio. Its sorta like a mix of C++ and Java.
__________________
System: The System
CPU
Q6600 @ 3.2Ghz - 356FSB
Motherboard
Asus P5Q Pro
Memory
OCZ Platinum Rev. 2 4x1GB
Graphics Card
EVGA 8800GT 512MB
Hard Drive
WD Raptor 150GB x 2
Sound Card
Creative X-Fi XtremeGamer
Power Supply
Corsair CMPSU-620HX 620W
Case
Antec P180B
CPU cooling
Scythe Ninja SCNJ-1000
OS
Windows Vista Ultimate x64
Monitor
Samsung 226BW 22" LCD
dante020 is offline I fold for Overclock.net   Reply With Quote
Old 02-26-08   #8 (permalink)
The Project Keeper
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Bel Air
Posts: 9,550
Blog Entries: 3

Rep: 278 Licht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 184
Folding Team Rank: 880
Trader Rating: 0
Default

Look in your documents, open the Visual Studio folder then the projects folder then the bin folder.

System: Uzicht #3
CPU
Athlon X2 5200+ Windsor
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
Saphire HD 3870
Hard Drive
2x WD 160GB 7,200RPM RAID0
Sound Card
X-Fi Extreme Gamer Fatality Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
AMD Stock Cooling
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows Vista Home Premium x64 SP1
Monitor
Samsung SyncMaster 19"Wide
Licht is offline I fold for Overclock.net Overclocked Account Licht's Gallery   Reply With Quote
Old 02-27-08   #9 (permalink)
First Time Build
 
intel nvidia

Join Date: May 2007
Location: Ak
Posts: 53

Rep: 1 Ecko Unknown
Unique Rep: 1
Trader Rating: 0
Default

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.
__________________
System: Titan
CPU
C2D E6600
Motherboard
ASUS P5N32E-SLI
Memory
4x1GB DDR2 800 G.Skill HZ
Graphics Card
EVGA 8800 GTS 640MB
Hard Drive
2xSeagate Barracuda 7200.10
Sound Card
Creative Sound Blaster X-Fi XtremeGamer 7.1
Power Supply
Corsair 620HX
Case
Something cheap
CPU cooling
Tuniq Tower 120
OS
XP
Monitor
Samsung 226BW 22" LCD Monitor
Ecko is offline   Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -4. The time now is 08:01 AM.


Overclock.net is a Carbon Neutral Site Creative Commons License Internet Security By ControlScan

Terms of Service / Forum Rules | Privacy Policy | Advertising | Become an Official Vendor
Copyright © 2008 Shogun Interactive Development. Most rights reserved.
Page generated in 0.25488 seconds with 8 queries