Need help to convert my C
To: comp.lang.java.gui
I'm currently exploring GUI with java and I've wrote a program in c++
to convert binary to decimal and a caesar cipher codes. Could anyone
help me to convert it to Java with GUI? I'd like to explore more on
GUI codings.
I've setup a GUI based on visual basic 6.0. it's uploaded on
http://img299.imageshack.us/img299/3698/fypgui1mf6.jpg
My c++ codings for both programs are as below.....
//================
//BINARY TO DECIMAL
//================
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
string bin;
int base = 10;
int result = 0;
int i;
double power = 0;
cout<<"Enter a binary number: ";
getline(cin, bin);
for (i = bin.length()-1; i >=0; i--)
{
result += ((bin[i]-48)*(pow(2,power)));
power++;
}
cout<<"decimal = "<<result<<endl;
system ("PAUSE");
return 0;
}
//==============
// CAESAR CIPHER
//==============
#include <iostream>
#include <string>
using namespace std;
int main()
{
int difference;
string msg;
int crypted;
int real_difference;
int i=0;
cout<<"Enter the offset : ";
cin>>difference;
cin.get();
if (difference > 26) //Brings back the number if above 26
{
real_difference = difference % 26;
}
else
real_difference = difference;
cout<<"Enter the message you want to crypt : ";
getline(cin, msg);
cout<<"Ciphertext: ";
while (i<= msg.length())
{
if(msg[i] == 32)
{
crypted = msg[i];
cout<<(char)crypted;
i++;
}
if ((msg[i] + real_difference) > 'z')
{
crypted = (msg[i] +
real_difference)-'z'+'a';
}
else
{
crypted = msg[i] + real_difference;
}
cout<<(char)crypted;
i++;
if(i>= msg.length())
break;
}
cout<<endl;
system ("PAUSE");
return 0;
}
Thanks in advance.
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24