Issue with menus and loops

Feb 24, 2017 at 3:54am
Hi, this is a project for my first C++ class. I've ran into a few issues though.
I'm not completely finished yet, but I thought I would fix these issues before creating more!

1)When entering an invalid entry, "Invalid Entry!!! will appear, but when I enter a valid menu choice entry after the invalid entry, the program will end.
2)When entering the Sub-menu's, the Main menu is still being displayed at the top... actually everything the program runs is displayed. How do I "clear" the past outputs?

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99


#include <iostream>
#include <cmath>
#include <Windows.h>

using namespace std;

void showMenu();
void showDistance();
void showWeight();
void showVolume();
void showPressure();
void showTemperature();
void inchtoCentimeter();
void foottoMeter();
void miletoKilometer();
void centimetertoInch();
void metertoFoot();


int main()
{

	cout.setf(ios::fixed);	//Output with two decimal points
	cout.setf(ios::showpoint);
	cout.precision(2);



	showMenu(); // Display Menu 



}

void showMenu()
{
	int choice;

	cout << endl;
	cout << "\tC O N V E R S I O N\n";
	cout << "\t<><><><><><><><><><>\n";
	cout << endl;
	cout << "\t1  Distance\n";
	cout << "\t2  Weight\n";
	cout << "\t3  Volume\n";
	cout << "\t4  Pressure\n";
	cout << "\t5  Temperature\n";
	cout << "\t6  End Program\n";
	cout << endl;
	cout << "\tEnter your choice:";
	cin >> choice;

	if (choice == 1)
	{
		showDistance();
	}
	if (choice == 2)
	{
		showWeight();
	}
	if (choice == 3)
	{
		showVolume();
	}
	if (choice == 4)
	{
		showPressure();
	}
	if (choice == 5)
	{
		showTemperature();
	}

	if (choice == 6)
	{
		cout << endl;
		cout << "Programmer: David Steemke";
		cout << endl;
		cout << endl;
		cout << "Press <Enter> key to end ... ";

		fflush(stdin); //empty input buffer  

		cin.get();      //read in a character


	}

	if (choice <= 0 || choice > 6)	// To error Invalid Entry 
	{
		cout << "\tInvalid Entry!!!\n";
		cout << "\tEnter your choice:";
		cin >> choice;
		system("pause");
		fflush(stdin);
	}
Feb 24, 2017 at 4:29am
To clear the screen, take a look at this link.

http://www.cplusplus.com/forum/articles/10515/
Feb 24, 2017 at 3:06pm
Thanks so much for the reply. I will implement this into my code.
Topic archived. No new replies allowed.