jaynajay's Profile
Reputation: 0
Apprentice
- Group:
- Members
- Active Posts:
- 26 (0.1 per day)
- Joined:
- 17-September 12
- Profile Views:
- 622
- Last Active:
Nov 12 2012 03:02 PM- Currently:
- Offline
Previous Fields
- Dream Kudos:
- 0
Posts I've Made
-
In Topic: ARRAYS get number, print number
Posted 8 Nov 2012
Thank You!!!! Its working now. -
In Topic: Calculator program using Functions
Posted 26 Oct 2012
Whew!
Finally, I was able to put this together. Could you please go through this real quick and advise me on any enhancement in the code. The code works now perfectly, with the exception that if the user enters any alph-letters. I tried to put a condition in the while statement, but then the program quits, rather than looping.
Once again, Thanks for the Help. Your suggestions really helped. Here is my code below that works now.
#include<iostream> using namespace std; void showMenu(); int getOption(int selection); void getNumbers(int& num1, int&num2); int addNumbers(int num1, int num2); int divideNumbers(int num1, int num2); int subtractNumbers(int num1, int num2); int multiplyNumbers(int num1, int num2); void displayResults(); int main () { displayResults(); /*system("pause");*/ return 0; } void showMenu() { cout<<"Enter---" <<endl; cout<<" 1: To add two numbers."<<endl; cout<<" 2: To divide two numbers. " <<endl; cout<<" 3: To subtract two number. " <<endl; cout<<" 4: To multiply two number. " <<endl; cout<<"99: To quit the program." <<endl; } int getOption(int selection) { cin>>selection; return selection; } void getNumbers(int& num1, int&num2) { cout<<"Enter two numbers: "; cin>>num1 >>num2; } int addNumbers(int num1, int num2) { return num1+num2; } int divideNumbers(int num1, int num2) { return num1/num2; } int subtractNumbers(int num1, int num2) { return num1 - num2; } int multiplyNumbers(int num1, int num2) { return num1 * num2; } void displayResults() { int num1, num2, sum, choice; do { showMenu(); cin>>choice; cout<<endl; switch (choice) { case 1: getNumbers(num1, num2); sum=addNumbers(num1, num2); cout<<num1 <<" + " <<num2 <<" = " <<sum <<"\n\n"; system("pause"); system("cls"); break; case 2: getNumbers(num1, num2); sum=divideNumbers(num1, num2); cout<<num1 <<" / " <<num2 <<" = " <<sum <<"\n\n"; system("pause"); system("cls"); break; case 3: getNumbers(num1, num2); sum=subtractNumbers(num1, num2); cout<<num1 <<" - " <<num2 <<" = " <<sum <<"\n\n"; system("pause"); system("cls"); break; case 4: getNumbers(num1, num2); sum=multiplyNumbers(num1, num2); cout<<num1 <<" * " <<num2 <<" = " <<sum <<"\n\n"; system("pause"); system("cls"); break; default: cout<<"Invalid input. Try again!" << "\n\n"; system("Pause"); } } while (choice == 1 || choice == 2 || choice ==3 || choice == 4); } -
In Topic: Calculator program using Functions
Posted 25 Oct 2012
Thanks for the reply Aphex19
output will be shown according to the option selected by the user. For example, if the user selects option 2. The output will be the division of 2 numbers.
I am going to change the function addNumbers the way you are suggesting, and will update shortly.
Thanks again! -
In Topic: Why my program won't loop
Posted 22 Oct 2012
Thanks for the reply, and sorry about not mentioning the loop i was talking about. I would like to loop the output for the user to enter phone numbers.
Also, I would definitely look into the good code habits, as suggested by you. Thanks again.
cout<<"\nThis program converts letters to their corresponding telephone digits" <<endl; 017 cout<<"Enter a phone number: "; cout<<"\nPhone Number before convert: "; cout<<"\nPhone Number after convert: " <<newLetters; 058 cout<<"\nTo stop the program enter #."; -
In Topic: Radio button selection not returning the results in the email
Posted 12 Oct 2012
IT WORKED!!!!!
Thanks Much for your time and the advise.
My Information
- Member Title:
- New D.I.C Head
- Age:
- Age Unknown
- Birthday:
- Birthday Unknown
- Gender:
Contact Information
- E-mail:
- Click here to e-mail me
Friends
jaynajay hasn't added any friends yet.
|
|


Find Topics
Find Posts
View Reputation Given
|
Comments
jaynajay has no profile comments yet. Why not say hello?