I am writing a program to calculate the area of shapes i've hit a problem everytime i run the program and input my choice it prints the start again-
Code:
#include <iostream>
using namespace std;
int main(){
int choice, w, l;
do{
cout << "Find the Area\n";
cout << "Please enter number of choice(q for quit): \n";
cout << "1. Square\n";
cout << "2. Rectangle\n";
cout << "3. Triangle\n";
cout << "4. Circle\n";
cout << "5. Cube\n";
cin >> choice;
} while ( choice < '1' || choice > '5' && choice != 'q' );
if (choice == 'q') exit(1);
switch (choice){
case '1':
cout << "\nEnter the width: ";
cin >> w;
cout << "\nArea is: " << w*w << "cm2";
case '2':
cout << "\nEnter the width: ";
cin >> w;
cout << "\nEnter the length: ";
cin >> l;
cout << "\nArea is: " << w*l << "cm2";
case '3':
cout << "\nEnter the width: ";
cin >> w;
cout << "\nEnter the height: ";
cin >> l;
cout << "\nArea is: " << 2/(w*l) << "cm2";
case '4':
cout << "\nEnter the radius: ";
cin >> w;
cout << "\nArea is: " << 3.14*(w*w) << "cm2";
case '5':
cout << "/nEnter the height: ";
cin >> l;
cout << "/nArea is: " << l*l*l << "cm3";
}
return 0;
}
Thanks for any help, it is much appreciated.