ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is it possible to convert java programming code to c++ code? I have a C++ program I need to turn in but did it in java first because that is what I know. I then go through and convert it manually...it makes it easier for me. Is there a way I can just convert the code with a tool?????? I use .NET
Any input is greatly appreciated as the program is due in a couple days
Microsoft makes a Java to C# conversion tool. Also ANTLER (a parser-parser) has some languages that may do the trick. However, it looks like you are under the gun with a deadline. I suggest that you make a pot of coffee and get to work. Fortunetly Java to C++ is fairly straightforward, not like Java to ... COBOL?
Okay thanks BubaDragon....but what is the Microsoft conversion tool called and how do I get it? That would help! Unless you just want to do it for me (joke)
Thanks!!
I don't think converting your Java to C# would be of much help... as C# and C++ are just about as different as Java and C++.
It seams to me, if you know Java well you should have the design philosophies down pretty well. If that is the case, then largely all your dealing with is syntax differences (ok... some other differences as well, but nothing that should be past your understand)... You'd probably be doing yourself a bigger favor if you got ride of your dependence on Java and just did everything from scratch in C++. It might be a little painful at first... but it is probably better for your learning.
The mark of a good programmer isn't his/her ability to code in a particular language.. it is his/her understand of programming and datatypes in general, and his/her ability to quickly pick up a new language in a new environment.
I am okay with C++ but not when it comes to array's. I am having a very hard time programming with arrays in C++! It is my only C++ class and I am not worried about knowing how to be a C++ programmer....since my bachelors is on Open Systems Technology (Linux administration) So it is very stressful trying to figure it out, thats why I would love to use a converter. The tutor that usually helps me out is on vacation
My code is as follows:
PHP Code:
#include <iostream> using std::cout; using std::cin; using std::endl;
#include <iomanip> using std::setw;
void assignPassenger(); int checkFlight(int, char); void printInfo();
int flight_number; char class_type; char repeat; char first_name[10], second_name[10]; int priceE = 0, priceF = 0, total_income;
int f1[10] = {0}; int f2[10] = {0}; int f3[10] = {0}; int availability;
int main() {
char new_passenger;
cout << "Do you want to assign a passenger ? " << "\t"; cin >> new_passenger;
while (new_passenger == 'y' || new_passenger == 'Y') { assignPassenger(); if(availability == 0) { cout << "Do you want to assign a new passenger ? " << "\t"; cin >> new_passenger; } else { cout << "Sorry, all the three flights are full" << endl; break; } } cout << "The total income of the economy class = " << priceE << endl; cout << "The total income of the first class = " << priceF << endl; total_income = priceE + priceF; cout << "The total income of the three flights = " << total_income << endl; cout << "__________________________________________________________" << endl << endl; cout << "You will see now how the three flight's seats look like (1 = reserved , 0 = empty)" << endl; printInfo ();
else { cout << "sorry, the the flight is full, Do you want to assign a seat in the same flight but in another class" << endl; cout << "or assign a seat in another flight?" << endl; cin >> repeat; } }
while (repeat == 'y' || repeat == 'Y');
}
int checkFlight(int flight_number, char class_type) { int full = 1; int i;
if (flight_number == 1 && class_type == 'f') {
for (i = 0 ; i < 5 ; i++) { if (f1[i] == 0) { full = 0; f1[i] = 1; }
if (full == 0) break;
} }
else if (flight_number == 1 && class_type == 'e') {
for (i = 5 ; i < 10 ; i++) { if (f1[i] == 0) { full = 0; f1[i] = 1; }
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.