Here's what I have at the moment:
#include %26lt;iostream%26gt;
#include %26lt;conio.h%26gt;
using namespace std;
int main()
{
char choice;
choice = toupper(choice);
int tableno;
int numoflines;
int multable;
int firstno;
int secondno;
char operation;
int calculation;
int i;
do
{
system(';CLS';);
cout%26lt;%26lt;';Do you want to create a Multiplication Table (M)';;
cout%26lt;%26lt;endl;
cout%26lt;%26lt;';Or perfrom a Calculation (C)?';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;choice;
while (choice !='M' || choice !='C')
cout%26lt;%26lt;';Please enter M or C only';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;choice;
switch (choice)
{
case 'M':
system(';CLS';);
cout%26lt;%26lt;';Please enter the Multiplication table number between 1 and 20';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;tableno;
if (tableno %26lt;1 || tableno %26gt;20)
{
cout%26lt;%26lt;';Multiplication table number should be between 1 and 20 only';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;tableno;
}
else
{
cout%26lt;%26lt;';Please enter the number of Lines between 1 and 15';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;numoflines;
}
if (numoflines %26lt;1 || numoflines %26gt;15)
{
cout%26lt;%26lt;';Number of Lines is not btetween 1 and 15';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;numoflines;
}
else
for (i=1; i%26lt;=numoflines; i++)
{
cout%26lt;%26lt;i;
cout%26lt;%26lt;'; x ';;
cout%26lt;%26lt;numoflines;
cout%26lt;%26lt;'; = ';;
multable = numoflines*i;
cout%26lt;%26lt;multable;
cout%26lt;%26lt;endl;
break;
}
case 'C':
system(';CLS';);
cout%26lt;%26lt;';Please enter your First number between 0 and 1000';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;firstno;
if (firstno %26lt;0 || firstno %26gt;1000)
{
cout%26lt;%26lt;';First number is not between 0 and 1000';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;firstno;
}
else
{
system(';CLS';);
cout%26lt;%26lt;';Please enter the Operator (+, -, *, / or %';;
cout%26lt;%26lt;endl;
cin%26gt;%26gt;operation;
system(';CLS';);
calculation = firstno; operation; secondno;
cout%26lt;%26lt;calculation;
}
if (operation ='%')
{
system(';CLS';);
cout%26lt;%26lt;';This is a modulus division which displays the remainder of an integer division';;
cout%26lt;%26lt;endl;
break;
}
}
}
return 0;
}Help with C++ menu coding for Multiplication Table and Calculator?
for my testing. it goes well
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment