ALCHEMISTA I NEED YOUR HELP!!! go to a new thread please!
okay here..
remember how yesterday we were doing the char choice stuff.. so right now I'm trying to add an option within an option basically..
so first it asks for: 1) Available converters 2) Problem solvers then depending on what i pick it takes me to converters, where i get to pick again
but i keep getting errors.. wait here's the code it's not finished yet though..
here
did u notice anything yet?
one second.
Main is missing an opening brace.
ohhh that's why thanks.. there's probably more stupid mistakes.. there
you have a strange switch statement before the menu display.
ah I see one second.
the problem is its grown considerably and you should really start splitting the program int separate routines but ill fix the problems for now
oh i see is there any neat way to split it up?
I mean i know what i'm supposed to do but there's just too much and it's like u have to pay attention..
// SolverandConverter.cpp : Defines the entry point for the console application. // #include <iostream> using namespace std; int converters () { char choice; float value; cout << "Available converters:" << endl << "1) Kilometers -> Meters" << endl << "2) Meters -> Kilometers" << endl << "3) Feet -> Meters" << endl << "4) Meters -> Feet" << endl << "5) Farenheit -> Celsius" << endl << "6) Leave menu" << endl; for ( ;; ) { cout << "Select: " << flush; cin >> choice; switch ( choice ) { case '1': cout << "Kilometers=" << flush; cin >> value; cout << value << " kilometers is " << value*1000.0 << " meters." << endl; break; case '2': cout << "Meters=" << flush; cin >> value; cout << value << " meters is " << value/1000.0 << " kilometers." << endl; break; case '3': cout<< "Feet=" << flush; cin >> value; cout << value << " feet is " << value*0.3048 << " meters." << endl; break; case '4': cout<< "Meters=" << flush; cin >> value; cout << value << " meters is " << value/0.3048 << " feet." << endl; break; case '5': cout<< "Farenheit=" << flush; cin >> value; cout << value << " Farenheit is " << (value-32.0)*(5.0/9.0) << " Celsius." << endl; break; case '6': return 0; default: cout << "Unknown choice!" << endl; break; } } } int solvers () { // add your stuff here return 0; } int main () { char choice; float value; for ( ;; ) { cout << "1) Available converters" << endl << "2) Problem solvers" << endl << "3) Exit" << endl << "Select: " << flush; cin >> choice; switch ( choice ) { case '1': converters (); break; case '2': solvers (); break; case '3': return 0; default: cout << "Unknown choice!" << endl; } } }
dang thanks!!
now alchemista im about to post a new question.. teach me how to split the program there..
Just study about the concept of functions in C++. How to define functions, declare the arguments etc.
Join our real-time social learning platform and learn together with your friends!