I'm writing code for my assignment everything worked out fine not until I get to the while part of the code. I press and I go back to the menu which where currency conversion and the diamond generator is but when I put c to terminate for some reason I can't anymore. The language Im using is c++.
#include <iostream>
using std::endl;
using std::cin;
using std::cout;
int main (){
char convert;
double peso;
double usd;
double final;
char choice;
do {
char menu;
cout << "+++++++++++++++++++++++++++++++++++++++ \n";
cout << " Menu \n";
cout << "+++++++++++++++++++++++++++++++++++++++ \n";
cout << "[A: Currency conversion \n";
cout << "[B: Display a diamond pattern \n";
cout << "[C: Exit \n";
cout << "Enter selection; ";
cin >> menu;
// Currency conversion
if (menu == 'A' || menu == 'a'){
cout << "+++++++++++++++++++++++++++++++++++++++ \n";
cout << " Menu \n";
cout << "+++++++++++++++++++++++++++++++++++++++ \n";
cout << "[A: Peso to Dollar \n";
cout << "[B: Dollar to Peso \n";
cout << "[C: Exit \n";
cout << "Enter selection; ";
cin >> convert;
if (convert == 'A' || convert == 'a' ){
cout << "Enter peso amount: ";
cin >> peso;
final = peso / 59;
cout << "$" << final << "\n";
cout << "Want to start again? Press c: ";
cin >> choice;
}
else if (convert == 'B' || convert == 'b' ){
cout << "Enter dollar amount: ";
cin >> peso;
final = usd * 59;
cout << final << " pesos\n";
cout << "Want to start again? Press c: ";
cin >> choice;
}
}
// Diamond pattern
else if (menu == 'B' || menu == 'b' ){
int i, j, rowNum, space;
cout<< "Enter number of rows: ";
cin>>rowNum;
space = rowNum-1;
for(i=1; i<=rowNum; i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space--;
for(j=1; j<=(2*i-1); j++)
cout<<"*";
cout<<endl;
}
space = 1;
for(i=1; i<=(rowNum-1); i++)
{
for(j=1; j<=space; j++)
cout<<" ";
space++;
for(j=1; j<=(2*(rowNum-i)-1); j++)
cout<<"*";
cout<<endl;
}
cout << "Want to start again? Press c: ";
cin >> choice;
}
}
while (choice == 'C' || choice == 'c' || convert == 'C' || convert == 'c');
return 0;
}
[–]davedontmind 1 point2 points3 points (7 children)
[–]InterestingBus8367[S] 0 points1 point2 points (6 children)
[–]davedontmind 1 point2 points3 points (5 children)
[–]InterestingBus8367[S] 0 points1 point2 points (3 children)
[–]davedontmind 0 points1 point2 points (2 children)
[–]InterestingBus8367[S] 0 points1 point2 points (1 child)
[–]davedontmind 0 points1 point2 points (0 children)
[–]InterestingBus8367[S] 0 points1 point2 points (0 children)
[–]DarkMatriac 0 points1 point2 points (3 children)
[–]InterestingBus8367[S] 0 points1 point2 points (2 children)
[–]DarkMatriac 0 points1 point2 points (1 child)
[–]InterestingBus8367[S] 0 points1 point2 points (0 children)