Converting area unit

Oct 12, 2014 at 10:30am
I need to convert unit between Square metres Square feet.Here is my a part of code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void Q1(){
	int opt;double UnitA;double UnitB;

	cout << "~Area conversion menu~" << endl;
	cout << "This program can convert area unit between square metres and square feet." << endl;
	cout << "Options (1 to 3) for:\n";
	cout << "(1) Converting a value from square metres to square feet.\n";
	cout << "(2) Converting a value from square feet to square metres.\n";
	cout << "(3) Exit and return to the Program Selection Menu.\n";
	
	cout << "Please input option here:";
	cin >> opt;
	
	switch (opt) {
	case 1:cout << "Please enter a number that you want to convert to square feet from square metres:";
	cin >> UnitA;
	cout << fixed << setprecision(2) << "The square feet unit is " << UnitA*10.764 << ".";
	case 2:cout << "Please enter a number that you want to convert to square metres from square feet:";
	cin >> UnitB;
	cout << setprecision(2) << "The square metres is " << UnitB/10.764 << ".";
	case 3:cout << "Goodbye!";break;
	default: cout << "Wrong input option";
	}
	

	


}


How can I show again the ~Area conversion menu~ and the followings after I convert a number.For example, I choose option 1,I input "1",and it show the square feets is 10.764, and then I want it show again ~Area conversion menu~ and the followings and the user can input other option(1 to 3)???
Oct 12, 2014 at 10:46am
1.) You need break statements for the cases unless, you intended for it to jump (ex input 1... executes 1,2,3).
2.) Consider a loop?
3.) Adding an exit option when loop implemented?

Last edited on Oct 12, 2014 at 10:55am
Topic archived. No new replies allowed.