|
![]() |
Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming > Application Programming | |
How do I give my C++ program a GUI / Turn it into a .exe?
|
||
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) | ||||||||||||
|
Overclocker in Training
|
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?
Last edited by Ecko : 02-26-08 at 08:55 PM. |
||||||||||||
|
|
|
|
|
#2 (permalink) | ||||||||||||
|
Intel Overclocker
|
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.
__________________
|
||||||||||||
|
|
|
|
#3 (permalink) | |||||||||||||
|
World's Best Boss
|
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.
__________________
|
|||||||||||||
|
|
|
|
#4 (permalink) | |||||||||||||
|
Windows Wrangler
|
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!
|
|||||||||||||
|
|
|
|
#5 (permalink) | |||||||||||||
|
World's Best Boss
|
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.
__________________
|
|||||||||||||
|
|
|
|
#6 (permalink) | |||||||
|
The 100 Mega Shock!
|
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.
__________________
|
|||||||
|
|
|
|
#7 (permalink) | ||||||||||||
|
Intel Overclocker
|
C# is actually pretty nifty. Visually create GUI with Visual Studio. Its sorta like a mix of C++ and Java.
__________________
|
||||||||||||
|
|
|
|
#8 (permalink) | |||||||||||||
|
Miscelaneous
|
Look in your documents, open the Visual Studio folder then the projects folder then the bin folder.
__________________
|
|||||||||||||
|
|
|
|
#9 (permalink) | |||||||||||||
|
Overclocker in Training
|
Quote:
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.
|
|||||||||||||
|
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
|
|