Basic Input C++

When I program in C++ I make up these scenarios. The scenarios are based on VERY basic things like just adding two numbers together. This is one of those codes that takes two numbers and adds them together, the only difference is, I added a hint of imagination :).

#include <iostream>

int additionCal( int numberA, int numberB );
void processorFunc( int processorType );

int main()
{
int choice;
int programExit;

system(“cls”);
std::cout << “\t\tWelcome to ProcessorCal 1.0.2 by Jonathan Vasquez\n\n”;
std::cout << “Please select a processor type:\n\n”;
std::cout << “1. Intel\n”;
std::cout << “2. AMD\n\n”;
std::cout << “Current Section: “;
std::cin >> choice;

switch( choice )
{
case 1:

processorFunc( choice );
break;
case 2:

processorFunc( choice );
break;
default:
std::cout << “Error .. Exiting Program !”;
break;
}

std::cout << “\n\nEnter any number and press [ ENTER ] to exit: “;
std::cin >> programExit;

system(“cls”);

return 0;

}

int additionCal( int numberA, int numberB )
{
return ( numberA + numberB );
}

void processorFunc( int processorType )
{
int localNumberA;
int localNumberB;
int additionCalAnswer;

if( processorType == 1 )
{
system(“cls”);
std::cout << “\t\tIntel Architecture Arithmitec Calculator ( x86 )\n\n”;
std::cout << “Enter 2 Numbers to be added . . .\n\n”;
std::cout << “Number A: “;
std::cin >> localNumberA;
system(“cls”);
std::cout << “\t\tIntel Architecture Arithmitec Calculator ( x86 )\n\n”;
std::cout << “Enter 2 Numbers to be added . . .\n\n”;
std::cout << “Number B: “;
std::cin >> localNumberB;

additionCalAnswer = additionCal( localNumberA, localNumberB );

system(“cls”);
std::cout << “\t\tIntel Architecture Arithmitec Calculator ( x86 )\n\n”;
std::cout << “The number ” << localNumberA << ” and ” << localNumberB << ” add up to ”
<< additionCalAnswer;
}

else if( processorType == 2 )
{
system(“cls”);
std::cout << “\t\tAMD Architecture Arithmitec Calculator ( x86 )\n\n”;
std::cout << “Enter 2 Numbers to be added . . .\n\n”;
std::cout << “Number A: “;
std::cin >> localNumberA;
system(“cls”);
std::cout << “\t\tAMD Architecture Arithmitec Calculator ( x86 )\n\n”;
std::cout << “Enter 2 Numbers to be added . . .\n\n”;
std::cout << “Number B: “;
std::cin >> localNumberB;

additionCalAnswer = additionCal( localNumberA, localNumberB );

system(“cls”);
std::cout << “\t\tAMD Architecture Arithmitec Calculator ( x86 )\n\n”;
std::cout << “The number ” << localNumberA << ” and ” << localNumberB << ” add up to ”
<< additionCalAnswer;
}

else
std::cout << “Error . . . Program Exiting !”;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: